bpo-37244: Fix test_multiprocessing.test_resource_tracker() (GH-14288)

Increase robustness of test_resource_tracker(): retry for 60 seconds.
(cherry picked from commit e1a63c4f21)

Co-authored-by: Pierre Glaser <pierreglaser@msn.com>
This commit is contained in:
Miss Islington (bot) 2019-06-25 15:49:31 -07:00 committed by GitHub
parent 4adc38e794
commit dd4edbc5ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 6 deletions

View File

@ -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 {} '