diff options
author | Sam Gross <colesbury@gmail.com> | 2024-05-02 17:41:15 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 17:41:15 (GMT) |
commit | 83c51da6cebdced80ebc59de70e8844244de7298 (patch) | |
tree | c4bfada4420524c806f0a85c9901d4696e912790 | |
parent | b28a3339e4c63ea3a801dba9bbbc6af5af42c3a0 (diff) | |
download | cpython-83c51da6cebdced80ebc59de70e8844244de7298.zip cpython-83c51da6cebdced80ebc59de70e8844244de7298.tar.gz cpython-83c51da6cebdced80ebc59de70e8844244de7298.tar.bz2 |
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.
-rw-r--r-- | Lib/test/_test_multiprocessing.py | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py index 91f8599..5fc4181 100644 --- a/Lib/test/_test_multiprocessing.py +++ b/Lib/test/_test_multiprocessing.py @@ -2804,7 +2804,6 @@ class _TestPool(BaseTestCase): # 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. @@ -2813,8 +2812,8 @@ class _TestPool(BaseTestCase): self.pool.map(identity, objs) del objs - gc.collect() # For PyPy or other GCs. time.sleep(DELTA) # let threaded cleanup code run + support.gc_collect() # For PyPy or other GCs. self.assertEqual(set(wr() for wr in refs), {None}) # With a process pool, copies of the objects are returned, check # they were released too. |