Skip to content

Commit 83c51da

Browse files
authored
gh-118413: Fix test_release_task_refs on free-threaded build (#118494)
The `time.sleep()` call should happen before the GC to give the worker threads time to clean-up their remaining references to objs. Additionally, use `support.gc_collect()` instead of `gc.collect()` just in case the extra GC calls matter.
1 parent b28a333 commit 83c51da

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

Lib/test/_test_multiprocessing.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2804,7 +2804,6 @@ def test_map_no_failfast(self):
28042804
# check that we indeed waited for all jobs
28052805
self.assertGreater(time.monotonic() - t_start, 0.9)
28062806

2807-
@support.requires_gil_enabled("gh-118413: test is flaky with GIL disabled")
28082807
def test_release_task_refs(self):
28092808
# Issue #29861: task arguments and results should not be kept
28102809
# alive after we are done with them.
@@ -2813,8 +2812,8 @@ def test_release_task_refs(self):
28132812
self.pool.map(identity, objs)
28142813

28152814
del objs
2816-
gc.collect() # For PyPy or other GCs.
28172815
time.sleep(DELTA) # let threaded cleanup code run
2816+
support.gc_collect() # For PyPy or other GCs.
28182817
self.assertEqual(set(wr() for wr in refs), {None})
28192818
# With a process pool, copies of the objects are returned, check
28202819
# they were released too.

0 commit comments

Comments
 (0)