[前][次][番号順一覧][スレッド一覧]

ruby-changes:34125

From: nobu <ko1@a...>
Date: Wed, 28 May 2014 15:05:49 +0900 (JST)
Subject: [ruby-changes:34125] nobu:r46206 (trunk): test/rake: avoid leaking threads

nobu	2014-05-28 15:05:43 +0900 (Wed, 28 May 2014)

  New Revision: 46206

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=46206

  Log:
    test/rake: avoid leaking threads
    
    * test/rake/test_rake_multi_task.rb (teardown): clean up thread
      pool to avoid leaking threads.
    
    * test/rake/test_rake_task_with_arguments.rb (teardown): ditto.
    
    * test/rake/test_rake_thread_pool.rb: ditto.

  Modified files:
    trunk/test/rake/test_rake_multi_task.rb
    trunk/test/rake/test_rake_task_with_arguments.rb
    trunk/test/rake/test_rake_thread_pool.rb
Index: test/rake/test_rake_multi_task.rb
===================================================================
--- test/rake/test_rake_multi_task.rb	(revision 46205)
+++ test/rake/test_rake_multi_task.rb	(revision 46206)
@@ -13,6 +13,12 @@ class TestRakeMultiTask < Rake::TestCase https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_multi_task.rb#L13
     @mutex = Mutex.new
   end
 
+  def teardown
+    Rake.application.thread_pool.join
+
+    super
+  end
+
   def add_run(obj)
     @mutex.synchronize do
       @runs << obj
Index: test/rake/test_rake_task_with_arguments.rb
===================================================================
--- test/rake/test_rake_task_with_arguments.rb	(revision 46205)
+++ test/rake/test_rake_task_with_arguments.rb	(revision 46206)
@@ -12,6 +12,7 @@ class TestRakeTaskWithArguments < Rake:: https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_task_with_arguments.rb#L12
 
   def teardown
     Rake::TaskManager.record_task_metadata = false
+    Rake.application.thread_pool.join
 
     super
   end
Index: test/rake/test_rake_thread_pool.rb
===================================================================
--- test/rake/test_rake_thread_pool.rb	(revision 46205)
+++ test/rake/test_rake_thread_pool.rb	(revision 46206)
@@ -33,6 +33,8 @@ class TestRakeTestThreadPool < Rake::Tes https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_thread_pool.rb#L33
     refute_equal threads[0], threads[1]
     refute_equal Thread.current, threads[0]
     refute_equal Thread.current, threads[1]
+  ensure
+    pool.join
   end
 
   def test_pool_creates_the_correct_number_of_threads
@@ -95,6 +97,8 @@ class TestRakeTestThreadPool < Rake::Tes https://github.com/ruby/ruby/blob/trunk/test/rake/test_rake_thread_pool.rb#L97
     assert_raises(CustomError) do
       pool.future(2, &deep_exception_block).value
     end
+  ensure
+    pool.join
   end
 
   def test_pool_prevents_deadlock

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]