lib/polyphony/extensions/thread.rb in polyphony-0.73.1 vs lib/polyphony/extensions/thread.rb in polyphony-0.74

- old
+ new

@@ -16,18 +16,24 @@ end def execute # backend must be created in the context of the new thread, therefore it # cannot be created in Thread#initialize - @backend = Polyphony::Backend.new + raise_error = false + begin + @backend = Polyphony::Backend.new + rescue Exception => e + raise_error = true + raise e + end setup @ready = true result = @block.(*@args) rescue Polyphony::MoveOn, Polyphony::Terminate => e result = e.value rescue Exception => e - result = e + raise_error ? (raise e) : (result = e) ensure @ready = true finalize(result) end @@ -46,10 +52,10 @@ @finalization_mutex.synchronize do @terminated = true @result = result signal_waiters(result) end - @backend.finalize + @backend&.finalize end def signal_waiters(result) @join_wait_queue.each { |w| w.signal(result) } end