Ruby 3 support Ractor to archive concurrency, Ractor can not access instance variables of classes/modules.
When I want to use Ractor with http, I found http is using access instance variables of classes, for example:
require 'http'
ractors = []
url = 'http://httpbin.org/ip'
10.times do
ractors << Ractor.new(url) { |u| HTTP.get u }
end
ractors.map(&:take)
This snippet will raise error http-4.4.1/lib/http/chainable.rb:221:in 'default_options': can not access instance variables of classes/modules from non-main Ractors (Ractor::IsolationError), because http using default_options as class instance variable.
Ruby 3 support
Ractor
to archive concurrency,Ractor
can not access instance variables of classes/modules.When I want to use
Ractor
withhttp
, I foundhttp
is using access instance variables of classes, for example:This snippet will raise error
http-4.4.1/lib/http/chainable.rb:221:in 'default_options': can not access instance variables of classes/modules from non-main Ractors (Ractor::IsolationError)
, becausehttp
usingdefault_options
as class instance variable.Is it possible to make it support
Ractor
?