bpo-34172: multiprocessing.Pool leaks resources after being deleted (… · python/cpython@97f998a · GitHub
Skip to content

Commit 97f998a

Browse files
miss-islingtontzickel
authored andcommitted
bpo-34172: multiprocessing.Pool leaks resources after being deleted (GH-8450) (GH-9676)
Fix a reference issue inside multiprocessing.Pool that caused the pool to remain alive if it was deleted without being closed or terminated explicitly. (cherry picked from commit 97bfe8d) Co-authored-by: tzickel <tzickel@users.noreply.github.com>
1 parent 484c899 commit 97f998a

3 files changed

Lines changed: 57 additions & 24 deletions

File tree

Lib/multiprocessing/pool.py

Lines changed: 50 additions & 24 deletions

Lib/test/_test_multiprocessing.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,6 +2551,12 @@ def test_release_task_refs(self):
25512551
# they were released too.
25522552
self.assertEqual(CountedObject.n_instances, 0)
25532553

2554+
def test_del_pool(self):
2555+
p = self.Pool(1)
2556+
wr = weakref.ref(p)
2557+
del p
2558+
gc.collect()
2559+
self.assertIsNone(wr())
25542560

25552561
def raising():
25562562
raise KeyError("key")
Lines changed: 1 addition & 0 deletions

0 commit comments

Comments
 (0)