Closed niku closed 1 year ago
I run into an unexpected behavior when I use fiber local variable in heder_converters block. To reproduce following:
~/csv (tags/v3.2.6) git checkout v3.2.5 HEAD is now at 502197b Add 3.2.5 entry ~/csv (tags/v3.2.5) bundle exec ruby -r csv -e 'p CSV::VERSION; main_fiber = Fiber.current; Thread.current[:a]="a"; CSV.new("id,name,age\n1,2,3\n", headers: true, header_converters: ->(h) { p [Fiber.current == main_fiber, Thread.current[:a]] }).to_a;' "3.2.5" [true, "a"] [true, "a"] [true, "a"] ~/csv (tags/v3.2.5) git checkout v3.2.6 Previous HEAD position was 502197b Add 3.2.5 entry HEAD is now at 816b48b Add 3.2.6 entry ~/csv (tags/v3.2.6) bundle exec ruby -r csv -e 'p CSV::VERSION; main_fiber = Fiber.current; Thread.current[:a]="a"; CSV.new("id,name,age\n1,2,3\n", headers: true, header_converters: ->(h) { p [Fiber.current == main_fiber, Thread.current[:a]] }).to_a;' "3.2.6" [false, nil] [false, nil] [false, nil]
I suppose it may not a bug. If so, feel free to close it. Thanks.
I think that acc05116c55579b78925dd27024969b9daf69135 is related.
It seems that Enumerator#each uses the same fiber but Enumerator#next uses a different fiber.
Enumerator#each
Enumerator#next
I run into an unexpected behavior when I use fiber local variable in heder_converters block. To reproduce following:
I suppose it may not a bug. If so, feel free to close it. Thanks.