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

ruby-changes:72240

From: Nobuyoshi <ko1@a...>
Date: Sun, 19 Jun 2022 23:39:59 +0900 (JST)
Subject: [ruby-changes:72240] da362fee59 (master): Scale the time to wait native threads to run hook

https://git.ruby-lang.org/ruby.git/commit/?id=da362fee59

From da362fee59b2bff30eb8d63ee15724f5c3aac957 Mon Sep 17 00:00:00 2001
From: Nobuyoshi Nakada <nobu@r...>
Date: Sun, 19 Jun 2022 23:33:26 +0900
Subject: Scale the time to wait native threads to run hook

---
 test/-ext-/thread/test_instrumentation_api.rb | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/test/-ext-/thread/test_instrumentation_api.rb b/test/-ext-/thread/test_instrumentation_api.rb
index adfb6443bc..61e219101c 100644
--- a/test/-ext-/thread/test_instrumentation_api.rb
+++ b/test/-ext-/thread/test_instrumentation_api.rb
@@ -1,4 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/-ext-/thread/test_instrumentation_api.rb#L1
 # frozen_string_literal: false
+require 'envutil'
+
 class TestThreadInstrumentation < Test::Unit::TestCase
   def setup
     pend("TODO: No windows support yet") if /mswin|mingw|bccwin/ =~ RUBY_PLATFORM
@@ -6,6 +8,8 @@ class TestThreadInstrumentation < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/thread/test_instrumentation_api.rb#L8
 
   THREADS_COUNT = 3
 
+  Give_more_time_to_the_native_threads_to_execute_their_EXIT_hook = EnvUtil.apply_timeout_scale(0.01)
+
   def test_thread_instrumentation
     require '-test-/thread/instrumentation'
     Bug::ThreadInstrumentation.reset_counters
@@ -19,7 +23,7 @@ class TestThreadInstrumentation < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/thread/test_instrumentation_api.rb#L23
         assert_predicate c,:nonzero?, "Call counters: #{counters.inspect}"
       end
 
-      sleep 0.01 # Give more time to the native threads to execute their EXIT hook
+      sleep(Give_more_time_to_the_native_threads_to_execute_their_EXIT_hook)
       assert_equal counters.first, counters.last # exited as many times as we entered
     ensure
       Bug::ThreadInstrumentation::unregister_callback
@@ -39,7 +43,7 @@ class TestThreadInstrumentation < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/-ext-/thread/test_instrumentation_api.rb#L43
         Bug::ThreadInstrumentation.reset_counters
         threads = threaded_cpu_work
         write_pipe.write(Marshal.dump(threads.map(&:status)))
-        sleep 0.01 # Give more time to the native threads to execute their EXIT hook
+        sleep(Give_more_time_to_the_native_threads_to_execute_their_EXIT_hook)
         write_pipe.write(Marshal.dump(Bug::ThreadInstrumentation.counters))
         write_pipe.close
         exit!(0)
-- 
cgit v1.2.1


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

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