Skip to content

Commit 53082a7

Browse files
committed
Relax test timing (bpo-29861) to avoid sporadic failures (python#1120)
(cherry picked from commit 685cdb9)
1 parent 9a4577a commit 53082a7

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎Lib/test/_test_multiprocessing.py‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2000,6 +2000,20 @@ def test_map_no_failfast(self):
20002000
# check that we indeed waited for all jobs
20012001
self.assertGreater(time.time() - t_start, 0.9)
20022002

2003+
def test_release_task_refs(self):
2004+
# Issue #29861: task arguments and results should not be kept
2005+
# alive after we are done with them.
2006+
objs = [CountedObject() for i in range(10)]
2007+
refs = [weakref.ref(o) for o in objs]
2008+
self.pool.map(identity, objs)
2009+
2010+
del objs
2011+
time.sleep(DELTA) # let threaded cleanup code run
2012+
self.assertEqual(set(wr() for wr in refs), {None})
2013+
# With a process pool, copies of the objects are returned, check
2014+
# they were released too.
2015+
self.assertEqual(CountedObject.n_instances, 0)
2016+
20032017

20042018
def raising():
20052019
raise KeyError("key")

0 commit comments

Comments
 (0)