1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Refactor fetch, X-treme termination!

This commit is contained in:
Mike Perham 2012-03-30 20:59:08 -07:00
parent 4d14c2f7fa
commit da01d927a6
2 changed files with 10 additions and 9 deletions

View file

@ -30,15 +30,16 @@ module Sidekiq
# a new fetch if the current fetch turned up nothing.
def fetch
watchdog('Fetcher#fetch died') do
queue = nil
msg = nil
Sidekiq.redis do |conn|
(queue, msg) = conn.blpop *@cmd
puts 'All quiet' unless msg
@mgr.assign! msg, queue.gsub(/\Aqueue:/, '') if msg
end
after(0) { fetch } if !msg
Sidekiq.redis { |conn| (queue, msg) = conn.blpop(*@cmd) }
if msg
@mgr.assign!(msg, queue.gsub(/\Aqueue:/, ''))
else
puts 'All quiet'
after(0) { fetch }
end
end
end

View file

@ -40,8 +40,8 @@ module Sidekiq
@done = true
@fetcher.terminate if @fetcher.alive?
@ready.each { |x| x.terminate if x.alive? }
@fetcher.terminate! if @fetcher.alive?
@ready.each { |x| x.terminate! if x.alive? }
@ready.clear
redis do |conn|