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

ruby-changes:32547

From: nobu <ko1@a...>
Date: Thu, 16 Jan 2014 14:54:42 +0900 (JST)
Subject: [ruby-changes:32547] nobu:r44626 (trunk): test_rinda.rb: timeout all thread

nobu	2014-01-16 14:54:33 +0900 (Thu, 16 Jan 2014)

  New Revision: 44626

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

  Log:
    test_rinda.rb: timeout all thread
    
    * test/rinda/test_rinda.rb (test_do_reply): stop all threads and
      show backtraces.

  Modified files:
    trunk/test/rinda/test_rinda.rb
Index: test/rinda/test_rinda.rb
===================================================================
--- test/rinda/test_rinda.rb	(revision 44625)
+++ test/rinda/test_rinda.rb	(revision 44626)
@@ -559,6 +559,15 @@ class TestRingServer < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L559
   end
 
   def test_do_reply
+    tl0 = Thread.list
+    tl = nil
+    th = Thread.new(Thread.current) do |mth|
+      sleep 1
+      (tl = Thread.list - tl0).each {|t|t.raise(Timeout::Error)}
+      mth.raise(Timeout::Error)
+    end
+    tl0 << th
+
     called = nil
 
     callback = proc { |ts|
@@ -567,11 +576,6 @@ class TestRingServer < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L576
 
     callback = DRb::DRbObject.new callback
 
-    th = Thread.new(Thread.current) do |mth|
-      sleep 15
-      mth.raise unless called
-    end
-
     @ts.write [:lookup_ring, callback]
 
     @rs.do_reply
@@ -585,6 +589,19 @@ class TestRingServer < Test::Unit::TestC https://github.com/ruby/ruby/blob/trunk/test/rinda/test_rinda.rb#L589
     end
 
     assert_same @ts, called
+  rescue Timeout::Error => e
+    if tl
+      bt = e.backtrace
+      tl.each do |t|
+        begin
+          t.value
+        rescue Timeout::Error => e
+          bt.unshift("")
+          bt[0, 0] = e.backtrace
+        end
+      end
+    end
+    raise Timeout::Error, "timeout", bt
   ensure
     th.kill if th
   end

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

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