Project

General

Profile

Actions

Feature #19346

closed

Add Ractor escape hatch Ractor.disable_isolation_checks! { }

Added by luke-gru (Luke Gruber) over 2 years ago. Updated over 2 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:111838]

Description

It would be nice to be able to autoload constants inside Ractors. I'm not sure why this is disabled right now because if autoloading is working properly inside threads
then my initial thought is that the autoload implementation should work inside Ractors.

I guess there's different parts to this:

registering the autoload:

Ractor.new { autoload :MyClass, 'myclass' }

Kicking off the autoload require

Ractor.new { MyClass }

This leads to the problem of calling rubygems require inside Ractors, as rubygems is not Ractor safe.
However, it's thread-safe so it should be able to be ractor safe too (we don't need the ractor isolation checks in rubygems require).
What if there was an API:

Ractor.disable_isolation_checks! do
   "..."
end

It would disable all Ractor isolation errors inside the block. Rubygems could be patched easily and other gems too that
are thread-safe and use synchronization around the class ivars and constants.

Of course it could be abused and would have to be used properly. Well it's just an idea, I'm sure other people have had the same idea before.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0