lib/toiler/actor/processor.rb in toiler-0.6.0 vs lib/toiler/actor/processor.rb in toiler-0.6.1

- old
+ new

@@ -11,11 +11,11 @@ :extend_callback, :executing, :thread def initialize(queue) @queue = queue @worker_class = Toiler.worker_class_registry[queue] - @executing = Concurrent::AtomicBoolean.new + @executing = false @thread = nil init_options end def default_executor @@ -27,16 +27,17 @@ end def on_message(msg) method, *args = msg send(method, *args) - rescue StandardError => e + rescue StandardError, SystemStackError => e + # rescue SystemStackError, if clients misbehave and cause a stack level too deep exception, we should be able to recover error "Processor #{queue} failed processing, reason: #{e.class}: #{e.message}\n#{e.backtrace.join("\n")}" end def executing? - executing.value + @executing end private def init_options @@ -68,20 +69,20 @@ ensure process_cleanup timer end def process_init - @executing.make_true + @executing = true @thread = Thread.current debug "Processor #{queue} begins processing..." end def process_cleanup(timer) debug "Processor #{queue} starts cleanup after perform..." timer.shutdown if timer ::ActiveRecord::Base.clear_active_connections! if defined? ActiveRecord processor_finished - @executing.make_false + @executing = false @thread = nil debug "Processor #{queue} finished cleanup after perform..." end def processor_finished