Skip to content

Commit

Permalink
Relax test timing (bpo-29861) to avoid sporadic failures (python#1120)
Browse files Browse the repository at this point in the history
(cherry picked from commit 685cdb9)
  • Loading branch information
pitrou committed Apr 14, 2017
1 parent 9a4577a commit 53082a7
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Lib/test/_test_multiprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -2000,6 +2000,20 @@ def test_map_no_failfast(self):
# check that we indeed waited for all jobs
self.assertGreater(time.time() - t_start, 0.9)

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
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 raising():
raise KeyError("key")
Expand Down

0 comments on commit 53082a7

Please sign in to comment.