Commit 64737e9a authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-33913: Fix test_multiprocessing_main_handling (GH-7972)

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.
parent d2cbfffc
...@@ -57,11 +57,13 @@ if __name__ == '__main__': ...@@ -57,11 +57,13 @@ if __name__ == '__main__':
p = Pool(5) p = Pool(5)
results = [] results = []
p.map_async(f, [1, 2, 3], callback=results.extend) p.map_async(f, [1, 2, 3], callback=results.extend)
deadline = time.time() + 60 # up to 60 s to report the results start_time = time.monotonic()
while not results: while not results:
time.sleep(0.05) time.sleep(0.05)
if time.time() > deadline: # up to 1 min to report the results
raise RuntimeError("Timed out waiting for results") dt = time.monotonic() - start_time
if dt > 60.0:
raise RuntimeError("Timed out waiting for results (%.1f sec)" % dt)
results.sort() results.sort()
print(start_method, "->", results) print(start_method, "->", results)
""" """
...@@ -85,11 +87,13 @@ set_start_method(start_method) ...@@ -85,11 +87,13 @@ set_start_method(start_method)
p = Pool(5) p = Pool(5)
results = [] results = []
p.map_async(int, [1, 4, 9], callback=results.extend) 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: while not results:
time.sleep(0.05) time.sleep(0.05)
if time.time() > deadline: # up to 1 min to report the results
raise RuntimeError("Timed out waiting for results") dt = time.monotonic() - start_time
if dt > 60.0:
raise RuntimeError("Timed out waiting for results (%.1f sec)" % dt)
results.sort() results.sort()
print(start_method, "->", results) print(start_method, "->", results)
""" """
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment