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

More robust shutdown logic, less round-trips to Redis

This commit is contained in:
Mike Perham 2013-11-17 13:23:26 -08:00
parent a65d854356
commit cd15131998

View file

@ -37,6 +37,7 @@ module Sidekiq
do_defer do do_defer do
@boss.async.real_thread(proxy_id, Thread.current) @boss.async.real_thread(proxy_id, Thread.current)
ack = true
begin begin
msg = Sidekiq.load_json(msgstr) msg = Sidekiq.load_json(msgstr)
klass = msg['class'].constantize klass = msg['class'].constantize
@ -50,12 +51,14 @@ module Sidekiq
end end
rescue Sidekiq::Shutdown rescue Sidekiq::Shutdown
# Had to force kill this job because it didn't finish # Had to force kill this job because it didn't finish
# within the timeout. # within the timeout. Don't acknowledge the work since
# we didn't properly finish it.
ack = false
rescue Exception => ex rescue Exception => ex
handle_exception(ex, msg || { :message => msgstr }) handle_exception(ex, msg || { :message => msgstr })
raise raise
ensure ensure
work.acknowledge work.acknowledge if ack
end end
end end