ruby-concurrency / concurrent-ruby

Modern concurrency tools including agents, futures, promises, thread pools, supervisors, and more. Inspired by Erlang, Clojure, Scala, Go, Java, JavaScript, and classic concurrency patterns.
https://ruby-concurrency.github.io/concurrent-ruby/
Other
5.68k stars 418 forks source link

SafeTaskExecutor respects local jump errors #932

Closed aaronjensen closed 2 years ago

aaronjensen commented 2 years ago

See: https://bugs.ruby-lang.org/issues/18474 And: https://github.com/ruby-concurrency/concurrent-ruby/issues/931

aaronjensen commented 2 years ago

A LocalJumpError will cause the synchronize block to break, meaning that result will never be set and success will never be set to true. Furthermore, it is not caught by the rescue so no reason is caught.

I consider it a “success” by setting success to true initially. It will only be considered a failure if an exception is caught.

Even though the synchronize block is short circuited, the return still evaluates, so this completes the promise with a success and nil value.

chrisseaton commented 2 years ago

Note that JRuby has a bug with local jumps in general, which will also impact this functionality.

task = -> { yield 42 }
puts :here

This is fixed in their master branch.