[Python-checkins] bpo-37244: Fix test_multiprocessing.test_resource_tracker() (GH-14288)

Miss Islington (bot) webhook-mailer at python.org
Tue Jun 25 18:49:36 EDT 2019


https://github.com/python/cpython/commit/dd4edbc5ad4cdb47e051e7cc0801d31d3786588b
commit: dd4edbc5ad4cdb47e051e7cc0801d31d3786588b
branch: 3.8
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-06-25T15:49:31-07:00
summary:

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


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

Co-authored-by: Pierre Glaser <pierreglaser at msn.com>

files:
M Lib/test/_test_multiprocessing.py

diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 07cf09aaa4ab..eef262d723da 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -5010,12 +5010,21 @@ def create_and_register_resource(rtype):
                 _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 {} '



More information about the Python-checkins mailing list