Project

General

Profile

Actions

Bug #18193

closed

Accessing global configuration from Ractors

Added by kirs (Kir Shatrov) about 3 years ago. Updated about 3 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.0.2p107
[ruby-core:105425]

Description

Consider a very common Ruby code with attr_accessor on a class:

class GlobalConfig
  class << self
    attr_accessor :option
  end
end

GlobalConfig.option = 123
GlobalConfig.freeze

puts GlobalConfig.frozen? # => true

r = Ractor.new do
  GlobalConfig.option
end

puts r.take

Right now, this fails can not access instance variables of classes/modules from non-main Ractors.

Is this considered a bug? If it is, I'd be happy to work on a fix.
To me, it seems like we should allow accessing frozen objects.

If this is expected behavior, then I'd like to open a conversation for how libraries and apps should expose things like global configuration for Ractors to consume.


Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Feature #17592: Ractor should allowing reading shareable class instance variablesClosedko1 (Koichi Sasada)Actions
Actions #1

Updated by Eregon (Benoit Daloze) about 3 years ago

  • Is duplicate of Feature #17592: Ractor should allowing reading shareable class instance variables added

Updated by Eregon (Benoit Daloze) about 3 years ago

#17592 would let this work but it has not been implemented yet, cc @ko1 (Koichi Sasada)

Actions #3

Updated by ko1 (Koichi Sasada) about 3 years ago

  • Status changed from Open to Closed
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0