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

Remove defer support, required for large execution stacks on Ruby 1.9

This commit is contained in:
Mike Perham 2014-02-01 20:49:42 -08:00
parent cd0fee8143
commit 25147c6653

View file

@ -34,32 +34,30 @@ module Sidekiq
msgstr = work.message
queue = work.queue_name
do_defer do
@boss.async.real_thread(proxy_id, Thread.current)
@boss.async.real_thread(proxy_id, Thread.current)
ack = true
begin
msg = Sidekiq.load_json(msgstr)
klass = msg['class'].constantize
worker = klass.new
worker.jid = msg['jid']
ack = true
begin
msg = Sidekiq.load_json(msgstr)
klass = msg['class'].constantize
worker = klass.new
worker.jid = msg['jid']
stats(worker, msg, queue) do
Sidekiq.server_middleware.invoke(worker, msg, queue) do
worker.perform(*cloned(msg['args']))
end
stats(worker, msg, queue) do
Sidekiq.server_middleware.invoke(worker, msg, queue) do
worker.perform(*cloned(msg['args']))
end
rescue Sidekiq::Shutdown
# Had to force kill this job because it didn't finish
# within the timeout. Don't acknowledge the work since
# we didn't properly finish it.
ack = false
rescue Exception => ex
handle_exception(ex, msg || { :message => msgstr })
raise
ensure
work.acknowledge if ack
end
rescue Sidekiq::Shutdown
# Had to force kill this job because it didn't finish
# within the timeout. Don't acknowledge the work since
# we didn't properly finish it.
ack = false
rescue Exception => ex
handle_exception(ex, msg || { :message => msgstr })
raise
ensure
work.acknowledge if ack
end
@boss.async.processor_done(current_actor)
@ -71,22 +69,6 @@ module Sidekiq
private
# We use Celluloid's defer to workaround tiny little
# Fiber stacks (4kb!) in MRI 1.9.
#
# For some reason, Celluloid's thread dispatch, TaskThread,
# is unstable under heavy concurrency but TaskFiber has proven
# itself stable.
NEED_DEFER = (RUBY_ENGINE == 'ruby' && RUBY_VERSION < '2.0.0')
def do_defer(&block)
if NEED_DEFER
defer(&block)
else
yield
end
end
def identity
@str ||= "#{hostname}:#{process_id}-#{Thread.current.object_id}:default"
end