summaryrefslogtreecommitdiffstats
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
authorPierre Glaser <pierreglaser@msn.com>2019-06-25 22:30:17 (GMT)
committerVictor Stinner <vstinner@redhat.com>2019-06-25 22:30:17 (GMT)
commite1a63c4f21011a3ae77dff624196561070c83446 (patch)
tree4ecf23dcec5bf51c29dd1eecf1362261eab2108b /Lib/test/_test_multiprocessing.py
parent594d9b9f58e1ef0a60b5ce9e590e0f45cd684f26 (diff)
downloadcpython-e1a63c4f21011a3ae77dff624196561070c83446.zip
cpython-e1a63c4f21011a3ae77dff624196561070c83446.tar.gz
cpython-e1a63c4f21011a3ae77dff624196561070c83446.tar.bz2
bpo-37244: Fix test_multiprocessing.test_resource_tracker() (GH-14288)
Increase robustness of test_resource_tracker(): retry for 60 seconds.
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py21
1 files changed, 15 insertions, 6 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 07cf09a..eef262d 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -5010,12 +5010,21 @@ class TestResourceTracker(unittest.TestCase):
_resource_unlink(name1, rtype)
p.terminate()
p.wait()
- time.sleep(2.0)
- with self.assertRaises(OSError) as ctx:
- _resource_unlink(name2, rtype)
- # docs say it should be ENOENT, but OSX seems to give EINVAL
- self.assertIn(
- ctx.exception.errno, (errno.ENOENT, errno.EINVAL))
+
+ deadline = time.monotonic() + 60
+ while time.monotonic() < deadline:
+ time.sleep(.5)
+ try:
+ _resource_unlink(name2, rtype)
+ except OSError as e:
+ # docs say it should be ENOENT, but OSX seems to give
+ # EINVAL
+ self.assertIn(e.errno, (errno.ENOENT, errno.EINVAL))
+ break
+ else:
+ raise AssertionError(
+ f"A {rtype} resource was leaked after a process was "
+ f"abruptly terminated.")
err = p.stderr.read().decode('utf-8')
p.stderr.close()
expected = ('resource_tracker: There appear to be 2 leaked {} '