Actions
Bug #19020
closedUnexpected timeout thread appears in ThreadGroup
Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0dev (2022-09-23T20:17:54Z master 912ea8257a) [x86_64-linux]
Description
The new timeout implementation creates a thread at the very first use.
This has the side effect, that this management thread appears in a surrounding ThreadGroup
.
See this example:
require "timeout"
threadgroup = ThreadGroup.new
thr = Thread.new do
Timeout.timeout(10){}
end
threadgroup.add(thr)
p after_add: threadgroup, list: threadgroup.list
sleep 0.2
p after_sleep: threadgroup, list: threadgroup.list
On ruby master branch the ThreadGroup lists this common management thread of the timeout library:
$ ruby test-threadgroup.rb
{:after_add=>#<ThreadGroup:0x00007f12f120adb8>, :list=>[#<Thread:0x00007f12f120acc8 test-threadgroup.rb:4 run>]}
{:after_sleep=>#<ThreadGroup:0x00007f12f120adb8>, :list=>[#<Thread:0x00007f12f120a1d8@Timeout stdlib thread /home/lars/.rvm/rubies/ruby-head/lib/ruby/3.2.0+2/timeout.rb:101 sleep_forever>]}
While older ruby versions don't show any timeout thread:
$ ruby test-threadgroup.rb
{:after_add=>#<ThreadGroup:0x0000556315b26b50>, :list=>[#<Thread:0x0000556315b26b28@test-threadgroup.rb:4 run>]}
{:after_sleep=>#<ThreadGroup:0x0000556315b26b50>, :list=>[]}
Updated by larskanis (Lars Kanis) about 2 years ago
A fix is here: https://github.com/ruby/timeout/pull/22
Updated by Eregon (Benoit Daloze) about 2 years ago
- Status changed from Open to Closed
Updated by mame (Yusuke Endoh) almost 2 years ago
- Related to Feature #19440: Deprecate ThreadGroup added
Actions
Like0
Like0Like0Like0