sidekiq-superworker 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,7 +17,7 @@ module Sidekiq
17
17
  raise "Job has nil jid: #{item}" if item['jid'].nil?
18
18
 
19
19
  subjob = find_subjob_by_jid(item['jid'])
20
- SuperjobProcessor.error(subjob.superjob_id, worker, item, exception)
20
+ SuperjobProcessor.error(subjob.superjob_id, worker, item, exception) if subjob
21
21
  end
22
22
 
23
23
  protected
@@ -29,13 +29,16 @@ module Sidekiq
29
29
  SubjobProcessor.complete(subjob) if subjob
30
30
  end
31
31
 
32
+ # The job may've been created outside of sidekiq-superworker, so a nil return value for
33
+ # this method isn't necessarily problematic
32
34
  def find_subjob_by_jid(jid)
33
35
  # The job may complete before the Subjob record is created; in case that happens,
34
36
  # we need to sleep briefly and requery.
35
- tries = 3
36
- while !(subjob = Subjob.find_by_jid(jid)) && tries > 0
37
- sleep 1
38
- tries -= 1
37
+ max_tries = 5
38
+ try = 0
39
+ while !(subjob = Subjob.find_by_jid(jid)) && try < max_tries
40
+ sleep 2 ** try
41
+ try += 1
39
42
  end
40
43
  subjob
41
44
  end
@@ -1,5 +1,5 @@
1
1
  module Sidekiq
2
2
  module Superworker
3
- VERSION = '0.0.3'
3
+ VERSION = '0.0.4'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq-superworker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2013-06-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq