lib/celluloid/actor.rb in celluloid-0.15.0.pre vs lib/celluloid/actor.rb in celluloid-0.15.0.pre2

- old
+ new

@@ -312,11 +312,11 @@ task(:invoke_block) { message.dispatch } when BlockResponse, Response message.dispatch else unless @receivers.handle_message(message) - Logger.debug "Discarded message (unhandled): #{message}" + Logger.debug "Discarded message (unhandled): #{message}" if $CELLULOID_DEBUG end end message end @@ -366,14 +366,18 @@ end # Run the user-defined finalizer, if one is set def run_finalizer finalizer = @subject.class.finalizer - if finalizer && @subject.respond_to?(finalizer, true) - task(:finalizer, :method_name => finalizer, :dangerous_suspend => true) { @subject.__send__(finalizer) } + return unless finalizer && @subject.respond_to?(finalizer, true) + + task(:finalizer, :method_name => finalizer, :dangerous_suspend => true) do + begin + @subject.__send__(finalizer) + rescue => ex + Logger.crash("#{@subject.class}#finalize crashed!", ex) + end end - rescue => ex - Logger.crash("#{@subject.class}#finalize crashed!", ex) end # Clean up after this actor def cleanup(exit_event) @mailbox.shutdown