lib/toiler/actor/fetcher.rb in toiler-0.6.0 vs lib/toiler/actor/fetcher.rb in toiler-0.6.1
- old
+ new
@@ -32,11 +32,12 @@
def on_message(msg)
@executing = true
method, *args = msg
send(method, *args)
- rescue StandardError => e
+ rescue StandardError, SystemStackError => e
+ # rescue SystemStackError, if we misbehave and cause a stack level too deep exception, we should be able to recover
error "Fetcher #{queue.name} raised exception #{e.class}: #{e.message}\n#{e.backtrace.join("\n")}"
ensure
@executing = false
end
@@ -91,10 +92,11 @@
tell [:assign_messages, msgs] if !msgs.nil? && !msgs.empty?
tell [:release_messages, max_number_of_messages]
tell :poll_messages
end
- poll_messages if should_poll?
+ # defer method execution to avoid recursion
+ tell :poll_messages if should_poll?
end
def should_poll?
free_processors / 2 > waiting_messages
end