Actions
Feature #21942
openAllow reading class variables from non-main Ractors
Feature #21942:
Allow reading class variables from non-main Ractors
Description
It's very common in Rails applications to use class variables, and today class variables aren't even allowed to be read inside a Ractor:
class Foo
# This is NOT allowed to be read in non-main Ractors
@@bar = 123
def self.bar; @@bar; end
# This is allowed to be read in non-main Ractors
@baz = 123
def self.baz; @baz; end
end
# This is OK
Ractor.new {
p Foo.baz
}.value
# Exception here
Ractor.new {
p Foo.bar
}.value
Output is like this:
test.rb:4:in 'Foo.bar': can not access class variables from non-main Ractors (@@bar from Foo) (Ractor::IsolationError)
from test.rb:10:in 'block in <main>'
Can we allow shareable values to cross the Ractor boundary, similar to class instance variables?
Just for reference, the Rails code in question is here.
Updated by tenderlovemaking (Aaron Patterson) about 9 hours ago
I sent a patch here
Updated by tenderlovemaking (Aaron Patterson) about 9 hours ago
- Assignee set to ractor
Actions