inst-jobs 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/delayed/backend/active_record.rb +3 -1
- data/lib/delayed/backend/redis/job.rb +7 -1
- data/lib/delayed/version.rb +1 -1
- data/spec/shared/shared_backend.rb +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17372b30ae01ad83a1a94d8fe5e3bcb38ad91155
|
4
|
+
data.tar.gz: 2104ebf5b0f2518dcbb6cded76454455df39aff4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad3bd5d9ff71acc4a012d8cdd1cfddd590719404f0774be0f25c98bcd97b2f477a263c378f187b8ec1b017a4d6876f4f55e165810734a56b395829dc210e8e8e
|
7
|
+
data.tar.gz: 5b14d39f433a8640d1636ccdbd74359679a8d71855a76f602ded2a73ffb2b3c9ab2820ded05b37a635a4afa532052304a6e50a35d4ea63f0cca8e3bff8caad88
|
@@ -212,7 +212,9 @@ module Delayed
|
|
212
212
|
batch_size *= worker_names.length if worker_names.is_a?(Array)
|
213
213
|
find_available(batch_size, queue, min_priority, max_priority)
|
214
214
|
end
|
215
|
-
|
215
|
+
if jobs.empty?
|
216
|
+
return worker_names.is_a?(Array) ? {} : nil
|
217
|
+
end
|
216
218
|
if Settings.select_random_from_batch
|
217
219
|
jobs = jobs.sort_by { rand }
|
218
220
|
end
|
@@ -234,7 +234,13 @@ class Job
|
|
234
234
|
# rather than just a job id, saving a round trip
|
235
235
|
job_attrs = functions.get_and_lock_next_available(worker_name, queue, min_priority, max_priority, db_time_now)
|
236
236
|
job = instantiate_from_attrs(job_attrs) # will return nil if the attrs are blank
|
237
|
-
|
237
|
+
if multiple_workers
|
238
|
+
if job.nil?
|
239
|
+
job = {}
|
240
|
+
else
|
241
|
+
job = { worker_name => job }
|
242
|
+
end
|
243
|
+
end
|
238
244
|
job
|
239
245
|
end
|
240
246
|
|
data/lib/delayed/version.rb
CHANGED
@@ -110,6 +110,11 @@ shared_examples_for 'a backend' do
|
|
110
110
|
@job = create_job
|
111
111
|
Delayed::Job.find_available(5).should include(@job)
|
112
112
|
end
|
113
|
+
|
114
|
+
it "returns an empty hash when asking for multiple jobs, and there aren't any" do
|
115
|
+
locked_jobs = Delayed::Job.get_and_lock_next_available(['worker1', 'worker2'])
|
116
|
+
locked_jobs.should == {}
|
117
|
+
end
|
113
118
|
end
|
114
119
|
|
115
120
|
context "when another worker is already performing an task, it" do
|