Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [ '3.2', '3.1', '3.0', '2.7', head, jruby, truffleruby-head ]
ruby: [ '3.2', '3.1', '3.0', '2.7', head, jruby, truffleruby, truffleruby-head ]
os: [ ubuntu-latest, macos-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
2 changes: 1 addition & 1 deletion lib/timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def self.create_timeout_thread
requests.reject!(&:done?)
end
end
ThreadGroup::Default.add(watcher)
ThreadGroup::Default.add(watcher) unless watcher.group.enclosed?
watcher.name = "Timeout stdlib thread"
watcher.thread_variable_set(:"\0__detached_thread__", true)
watcher
Expand Down
13 changes: 13 additions & 0 deletions test/test_timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,17 @@ def test_threadgroup
end;
end

# https://github.com/ruby/timeout/issues/24
def test_handling_enclosed_threadgroup
assert_separately(%w[-rtimeout], <<-'end;')
Thread.new {
t = Thread.current
group = ThreadGroup.new
group.add(t)
group.enclose

assert_equal 42, Timeout.timeout(1) { 42 }
}.join
end;
end
end