summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Glaser <pierreglaser@msn.com>2019-05-17 18:20:07 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-05-17 18:20:07 (GMT)
commitcbe72d842646ded2454784679231e3d1e6252e72 (patch)
tree9d8d2051de1154d7993455c561f3af0c96e24023
parent3ea702eca17c4ab5209d823fac2463307dde0633 (diff)
downloadcpython-cbe72d842646ded2454784679231e3d1e6252e72.zip
cpython-cbe72d842646ded2454784679231e3d1e6252e72.tar.gz
cpython-cbe72d842646ded2454784679231e3d1e6252e72.tar.bz2
bpo-36867: _test_multiprocessing: avoid weak sync primitive (GH-13292)
Avoid weak sync primitive in multiprocessing resource_tracker test.
-rw-r--r--Lib/test/_test_multiprocessing.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 772c963..78ec53b 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -3945,11 +3945,19 @@ class _TestSharedMemory(BaseTestCase):
# segment should not leak the given memory segment.
p.terminate()
p.wait()
- time.sleep(1.0) # wait for the OS to collect the segment
- # The shared memory file was deleted.
- with self.assertRaises(FileNotFoundError):
- smm = shared_memory.SharedMemory(name, create=False)
+ deadline = time.monotonic() + 60
+ t = 0.1
+ while time.monotonic() < deadline:
+ time.sleep(t)
+ t = min(t*2, 5)
+ try:
+ smm = shared_memory.SharedMemory(name, create=False)
+ except FileNotFoundError:
+ break
+ else:
+ raise AssertionError("A SharedMemory segment was leaked after"
+ " a process was abruptly terminated.")
if os.name == 'posix':
# A warning was emitted by the subprocess' own