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

Commit 97bfe8d

Browse files
tzickelpitrou
authored andcommitted
bpo-34172: multiprocessing.Pool leaks resources after being deleted (GH-8450)
Fix a reference issue inside multiprocessing.Pool that caused the pool to remain alive if it was deleted without being closed or terminated explicitly.
1 parent 9012a0f commit 97bfe8d

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
@@ -2549,6 +2549,12 @@ def test_release_task_refs(self):
25492549
# they were released too.
25502550
self.assertEqual(CountedObject.n_instances, 0)
25512551

2552+
def test_del_pool(self):
2553+
p = self.Pool(1)
2554+
wr = weakref.ref(p)
2555+
del p
2556+
gc.collect()
2557+
self.assertIsNone(wr())
25522558

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

0 commit comments

Comments
 (0)