aboutsummaryrefslogtreecommitdiffstats
path: root/test/thread/test_queue.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-26 05:01:33 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-26 05:01:33 +0000
commit501afa013498079ba8d2bd047e86430fe17d2325 (patch)
treecdc869da7500c39e1bb7fa9d43533ab0dfde3687 /test/thread/test_queue.rb
parent00f78058b64bdc8dd4f085bcd37bfb21961faa0e (diff)
downloadruby-501afa013498079ba8d2bd047e86430fe17d2325.tar.gz
test/thread: fix leaked threads
* test/thread/test_{queue,sync}.rb: join work threads not to leak threads. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46130 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/thread/test_queue.rb')
-rw-r--r--test/thread/test_queue.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/test/thread/test_queue.rb b/test/thread/test_queue.rb
index cda76ce61c..e1ead47197 100644
--- a/test/thread/test_queue.rb
+++ b/test/thread/test_queue.rb
@@ -62,6 +62,8 @@ class TestQueue < Test::Unit::TestCase
sleep 0.01 until t1.stop?
q.max = q.max + 1
assert_equal before + 1, q.max
+ ensure
+ t1.join if t1
end
def test_queue_pop_interrupt
@@ -206,6 +208,13 @@ class TestQueue < Test::Unit::TestCase
assert_nothing_raised(TimeoutError) do
timeout(1) { th2.join }
end
+ ensure
+ [th1, th2].each do |th|
+ if th and th.alive?
+ th.wakeup
+ th.join
+ end
+ end
end
def test_dup