Skip to content

incompatible with ractors #53

Description

@HoneyryderChuck

currently, timeout can't be used in ractors:

Ractor.new do
  Timeout.timeout(4) do
    sleep(5)
  end
end.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.

Activity

  1. eregon commented on Oct 29, 2024

    @eregon
    Member

    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

  2. HoneyryderChuck commented on Oct 29, 2024

    @HoneyryderChuck
    Author

    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.

  3. jsvd commented on Jan 17, 2025

    @jsvd
  4. eregon commented on Jan 17, 2025

    @eregon
    Member

    @jsvd I don't consider this related, so that would be best as its own discussion or issue.

  5. jsvd commented on Jan 17, 2025

    @jsvd

    @eregon fair enough, I moved the comment to a new issue #58

  6. eregon commented on Dec 5, 2025

    @eregon
    Member

    Fixed in #75 (thanks @ko1!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions