Project

General

Profile

Actions

Bug #19020

closed

Unexpected timeout thread appears in ThreadGroup

Added by larskanis (Lars Kanis) about 2 years ago. Updated about 2 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 3.2.0dev (2022-09-23T20:17:54Z master 912ea8257a) [x86_64-linux]
[ruby-core:110053]

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=>[]}

Related issues 1 (1 open0 closed)

Related to Ruby master - Feature #19440: Deprecate ThreadGroupOpenActions

Updated by Eregon (Benoit Daloze) about 2 years ago

  • Status changed from Open to Closed
Actions #3

Updated by mame (Yusuke Endoh) almost 2 years ago

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0