Skip to content

Instantly share code, notes, and snippets.

@colesbury
Created May 1, 2024 22:42
Show Gist options
  • Save colesbury/f8ba31699eb6fcc79a29a2dd4e41e817 to your computer and use it in GitHub Desktop.
Save colesbury/f8ba31699eb6fcc79a29a2dd4e41e817 to your computer and use it in GitHub Desktop.
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 91f8599011..ef02ced1c2 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -2804,21 +2804,21 @@ def test_map_no_failfast(self):
# check that we indeed waited for all jobs
self.assertGreater(time.monotonic() - t_start, 0.9)
- @support.requires_gil_enabled("gh-118413: test is flaky with GIL disabled")
def test_release_task_refs(self):
- # Issue #29861: task arguments and results should not be kept
- # alive after we are done with them.
- objs = [CountedObject() for i in range(10)]
- refs = [weakref.ref(o) for o in objs]
- self.pool.map(identity, objs)
-
- del objs
- gc.collect() # For PyPy or other GCs.
- time.sleep(DELTA) # let threaded cleanup code run
- self.assertEqual(set(wr() for wr in refs), {None})
- # With a process pool, copies of the objects are returned, check
- # they were released too.
- self.assertEqual(CountedObject.n_instances, 0)
+ for _ in range(100):
+ # Issue #29861: task arguments and results should not be kept
+ # alive after we are done with them.
+ objs = [CountedObject() for i in range(10)]
+ refs = [weakref.ref(o) for o in objs]
+ self.pool.map(identity, objs)
+
+ del objs
+ gc.collect() # For PyPy or other GCs.
+ time.sleep(DELTA) # let threaded cleanup code run
+ self.assertEqual(set(wr() for wr in refs), {None})
+ # With a process pool, copies of the objects are returned, check
+ # they were released too.
+ self.assertEqual(CountedObject.n_instances, 0)
def test_enter(self):
if self.TYPE == 'manager':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment