[Python-checkins] bpo-33913: Fix test_multiprocessing_main_handling (GH-7972) (GH-7976)

Victor Stinner webhook-mailer at python.org
Wed Jun 27 17:14:57 EDT 2018


https://github.com/python/cpython/commit/1d06be8cc55715be8c32ec3b462adfb3a7839dfe
commit: 1d06be8cc55715be8c32ec3b462adfb3a7839dfe
branch: 3.6
author: Victor Stinner <vstinner at redhat.com>
committer: GitHub <noreply at github.com>
date: 2018-06-27T23:14:53+02:00
summary:

bpo-33913: Fix test_multiprocessing_main_handling (GH-7972) (GH-7976)

bpo-30339, bpo-33913:

* Increase timeout from 10 seconds to 1 minute in
  test_source_main_skipped_in_children source of
  test_multiprocessing_main_handling.
* Replace time.time() with time.monotonic().
* On timeout, include the duration in the error message.

(cherry picked from commit 64737e9ae2081e529935ecf07f44e89f362d1c4b)

files:
M Lib/test/test_multiprocessing_main_handling.py

diff --git a/Lib/test/test_multiprocessing_main_handling.py b/Lib/test/test_multiprocessing_main_handling.py
index 32593dab86da..e1b8d30f6a4c 100644
--- a/Lib/test/test_multiprocessing_main_handling.py
+++ b/Lib/test/test_multiprocessing_main_handling.py
@@ -58,11 +58,13 @@ def f(x):
     p = Pool(5)
     results = []
     p.map_async(f, [1, 2, 3], callback=results.extend)
-    deadline = time.time() + 10 # up to 10 s to report the results
+    start_time = time.monotonic()
     while not results:
         time.sleep(0.05)
-        if time.time() > deadline:
-            raise RuntimeError("Timed out waiting for results")
+        # up to 1 min to report the results
+        dt = time.monotonic() - start_time
+        if dt > 60.0:
+            raise RuntimeError("Timed out waiting for results (%.1f sec)" % dt)
     results.sort()
     print(start_method, "->", results)
 """
@@ -86,11 +88,13 @@ def f(x):
 p = Pool(5)
 results = []
 p.map_async(int, [1, 4, 9], callback=results.extend)
-deadline = time.time() + 10 # up to 10 s to report the results
+start_time = time.monotonic()
 while not results:
     time.sleep(0.05)
-    if time.time() > deadline:
-        raise RuntimeError("Timed out waiting for results")
+    # up to 1 min to report the results
+    dt = time.monotonic() - start_time
+    if dt > 60.0:
+        raise RuntimeError("Timed out waiting for results (%.1f sec)" % dt)
 results.sort()
 print(start_method, "->", results)
 """



More information about the Python-checkins mailing list