From: Roger Pack Date: 2009-07-18T20:23:46+09:00 Subject: [ruby-core:24426] Re: [Bug #1717] Thread local variables not visible from within a Fiber > You could even do: > > �class Thread > � �def self.inherit > � � �parent = Thread.current > � � �new do > � � � �parent.keys.each do |key| > � � � � �next if key =~ /^__/ > � � � � �Thread.current[key] = parent[key] > � � � �end > � � � �yield > � � �end > � �end > �end > > Which would be used like Thread.new, but automatically copy the parent's thread-locals to the new thread. It would seem that something like that is probably necessary to preserve sanity among thread's and fibers. Another option would be to allow for Fiber#[] to work. That would be less surprising to me than having Thread.current[] magically be assigning to two different places, depending on context. But they'd both require some shenanigens, as if you wanted to allow library users to write "blind" code you'd have to remap Thread.current[] to use Fiber.current[] when called within a running fiber. Still more code to write but seems more explicit to me and less surprising. Just thinking out loud. =r