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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6319beb67c1232acefb48870136662c958970b22
4
- data.tar.gz: 0f4051eda72fa6fe638924b62a35ab6ff7714595
3
+ metadata.gz: 17372b30ae01ad83a1a94d8fe5e3bcb38ad91155
4
+ data.tar.gz: 2104ebf5b0f2518dcbb6cded76454455df39aff4
5
5
  SHA512:
6
- metadata.gz: 8b69032f63bac4ef84c16812eab90e9ae7cea727545c4cdf3d276bd726715b7f7725f2f22d51e469a3d94815252147bc31263bda9ce9b085344ac63cbd956d06
7
- data.tar.gz: beda3ba76d7e9314e19464a263ea2a05fdc66866c1672e8049c50e7c7402b38c0ccb1e9272041badf6ea4f7a06d8a789f33b2475037347c05237bdb8932d91fa
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
- return nil if jobs.empty?
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
- job = { worker_name => job } if multiple_workers
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
 
@@ -1,3 +1,3 @@
1
1
  module Delayed
2
- VERSION = "0.12.0"
2
+ VERSION = "0.12.1"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inst-jobs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.12.0
4
+ version: 0.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke