Skip to content

Commit

Permalink
Styles
Browse files Browse the repository at this point in the history
  • Loading branch information
mhenrixon committed Jun 20, 2018
1 parent 0b95a06 commit 3fb664d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
18 changes: 7 additions & 11 deletions lib/sidekiq_unique_jobs/lock/until_executed.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,23 @@ class UntilExecuted < BaseLock
OK ||= 'OK'

def execute(callback)
operative = true
@operative = true
yield if block_given?
rescue Sidekiq::Shutdown
operative = false
@operative = false
raise
ensure
unlock_and_callback(operative, callback)
unlock_and_callback(callback)
end

private

def unlock_and_callback(operative, callback)
return notify_about_manual_unlock unless operative

def unlock_and_callback(callback)
return notify_about_manual_unlock unless @operative
unlock

if locked?
notify_about_manual_unlock
else
callback.call
end
return notify_about_manual_unlock if locked?
callback.call
end

def notify_about_manual_unlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
jid = UntilExecutedJob.perform_async
item = Sidekiq::Queue.new(queue).find_job(jid).item

locksmith = SidekiqUniqueJobs::Locksmith.new(item)

exists_key = 'uniquejobs:7f28fc7bce5b2f7ea9895080e9b2d282:EXISTS'
expect(get_key(exists_key)).to eq('1')
set_key(exists_key, 'NOT_DELETED')
Expand Down

0 comments on commit 3fb664d

Please sign in to comment.