You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ractor.newdoTimeout.timeout(4)dosleep(5)endend.take# .rubies/ruby-3.3.0/lib/ruby/3.3.0/timeout.rb:129:in `ensure_timeout_thread_created': can not access non-shareable objects in # # constant Timeout::TIMEOUT_THREAD_MUTEX by non-main ractor. (Ractor::IsolationError)# from .rubies/ruby-3.3.0/lib/ruby/3.3.0/timeout.rb:178:in `timeout'# from (irb):8:in `block in <top (required)>'
Lots of downstream dependencies rely on timeout, and this makes them unusable under ractors.
I think Thread in general is considered incompatible with Ractor (it breaks the programming model and there are several bugs with Ractor & threads), and so Timeout (which needs threads) is incompatible with Ractor.
I wouldn't go so far. If timeout would use ractor-local thread/queue/cond/mutex, it'd work. A completely alternative ractor-friendly implementation could also be an option (although I can't think of one). Was just pointing out that, the way it's implemented, it's unusable.
Activity
eregon commentedon Oct 29, 2024
I think Thread in general is considered incompatible with Ractor (it breaks the programming model and there are several bugs with Ractor & threads), and so Timeout (which needs threads) is incompatible with Ractor.
Also: https://bugs.ruby-lang.org/issues/18139#note-2
HoneyryderChuck commentedon Oct 29, 2024
I wouldn't go so far. If
timeoutwould use ractor-local thread/queue/cond/mutex, it'd work. A completely alternative ractor-friendly implementation could also be an option (although I can't think of one). Was just pointing out that, the way it's implemented, it's unusable.jsvd commentedon Jan 17, 2025
eregon commentedon Jan 17, 2025
@jsvd I don't consider this related, so that would be best as its own discussion or issue.
jsvd commentedon Jan 17, 2025
@eregon fair enough, I moved the comment to a new issue #58
eregon commentedon Dec 5, 2025
Fixed in #75 (thanks @ko1!)