backburner-allq 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0aea14c4ca2fa04f46e103f147d265c60a79cbcfab02c76ab5cfc333683cbbf3
4
- data.tar.gz: '08768dfb235b89694e401a67e20f963ec0bff7f9bdbaaceb178e7995e884d7cd'
3
+ metadata.gz: 2a73b5d7a8f60e385a3f600bfded5c0579691bbafdd4bc15b0f51e0df7298f4f
4
+ data.tar.gz: 26000c93ce60b0f53ff666f51f7fcd1549ddde403dd400f7f4c457e056803c92
5
5
  SHA512:
6
- metadata.gz: e43b3ae23ce17153380d0b2d03ff98344dabb2002e287edde44b3d878b08989671391d29ed8617c756a296f07962ebb4580421bb826a7ad7a2b2e30bd26e9bf7
7
- data.tar.gz: d8ae8904ede1db1c330674134a4301b1658b98bb69a268fbe20fda986590b29747216ea40e68d287979f9fa2f6439e727e95432927fe35a86c74897d9ba4c0d3
6
+ metadata.gz: a0d2079019d65e529e6b769ec860456bd13b2a29caf6797adcea9c1feca0f3b397d006ac9cd3e8a85e9d78a86af4ef8964d500d5822b001f730123705d80ada3
7
+ data.tar.gz: 747c8436582124a553424a1e674ae97a44fee865f74720fbe5e84ca5fc6006a05087a7e1c079a6acdb72c2414c7b94db0642fefbba886734d8b575735411ecbb
data/deploy.sh CHANGED
@@ -1,3 +1,3 @@
1
1
  echo "Did you update the version?"
2
2
  gem build backburner-allq.gemspec
3
- gem push backburner-allq-1.0.16.gem
3
+ gem push backburner-allq-1.0.17.gem
@@ -1,3 +1,3 @@
1
1
  module Backburner
2
- VERSION = "1.0.16"
2
+ VERSION = "1.0.17"
3
3
  end
@@ -134,35 +134,38 @@ module Backburner
134
134
  return
135
135
  end
136
136
 
137
- self.log_job_begin(job.name, job.args)
138
- job.process
139
- self.log_job_end(job.name)
140
-
141
- rescue Backburner::Job::JobFormatInvalid => e
142
- self.log_error self.exception_message(e)
143
- rescue => e # Error occurred processing job
144
- self.log_error self.exception_message(e) unless e.is_a?(Backburner::Job::RetryJob)
137
+ if job
138
+ self.log_job_begin(job.name, job.args)
139
+ job.process
140
+ self.log_job_end(job.name)
141
+
142
+ rescue Backburner::Job::JobFormatInvalid => e
143
+ self.log_error self.exception_message(e)
144
+ rescue => e # Error occurred processing job
145
+ self.log_error self.exception_message(e) unless e.is_a?(Backburner::Job::RetryJob)
146
+
147
+ unless job
148
+ self.log_error "Error occurred before we were able to assign a job. Giving up without retrying!"
149
+ return
150
+ end
145
151
 
146
- unless job
147
- self.log_error "Error occurred before we were able to assign a job. Giving up without retrying!"
148
- return
149
- end
152
+ # NB: There's a slight chance here that the connection to allq has
153
+ # gone down between the time we reserved / processed the job and here.
154
+ num_retries = job.releases
155
+ max_job_retries = resolve_max_job_retries(job.job_class)
156
+ retry_status = "failed: attempt #{num_retries+1} of #{max_job_retries+1}"
157
+ retry_delay = resolve_retry_delay(job.job_class)
158
+ delay = resolve_retry_delay_proc(job.job_class).call(retry_delay, num_retries) rescue retry_delay
159
+ if num_retries + 1 > max_job_retries
160
+ job.bury
161
+ else
162
+ job.release(delay)
163
+ end
164
+ self.log_job_end(job.name, "#{retry_status}, retrying in #{delay}s") if job_started_at
150
165
 
151
- # NB: There's a slight chance here that the connection to allq has
152
- # gone down between the time we reserved / processed the job and here.
153
- num_retries = job.releases
154
- max_job_retries = resolve_max_job_retries(job.job_class)
155
- retry_status = "failed: attempt #{num_retries+1} of #{max_job_retries+1}"
156
- retry_delay = resolve_retry_delay(job.job_class)
157
- delay = resolve_retry_delay_proc(job.job_class).call(retry_delay, num_retries) rescue retry_delay
158
- if num_retries + 1 > max_job_retries
159
- job.bury
160
- else
161
- job.release(delay)
166
+ handle_error(e, job.name, job.args, job)
162
167
  end
163
- self.log_job_end(job.name, "#{retry_status}, retrying in #{delay}s") if job_started_at
164
-
165
- handle_error(e, job.name, job.args, job)
168
+ job
166
169
  end
167
170
 
168
171
 
@@ -175,7 +178,9 @@ module Backburner
175
178
 
176
179
  # Reserve a job from the watched queues
177
180
  def reserve_job(conn, reserve_timeout = Backburner.configuration.reserve_timeout)
178
- Backburner::Job.new(conn.get(@tube_names.sample))
181
+ job = conn.get(@tube_names.sample)
182
+ return nil if job.body == nil?
183
+ Backburner::Job.new(job)
179
184
  end
180
185
 
181
186
  # Returns a list of all tubes known within the system
@@ -207,7 +207,9 @@ module Backburner
207
207
  def run_while_can(conn = connection)
208
208
  while @garbage_after.nil? or @garbage_after > @runs
209
209
  @runs += 1 # FIXME: Likely race condition
210
- work_one_job(conn)
210
+ ran_job = work_one_job(conn)
211
+ # Wait a second if we didn't find a job
212
+ sleep(rand() * 3) unless ran_job
211
213
  end
212
214
  end
213
215
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backburner-allq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.16
4
+ version: 1.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Malcolm