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

Commit 07b96a9

Browse files
miss-islingtontzickel
authored andcommitted
bpo-34172: multiprocessing.Pool leaks resources after being deleted (GH-8450) (GH-9677)
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 58376c6 commit 07b96a9

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
@@ -2285,6 +2285,12 @@ def test_release_task_refs(self):
22852285
# they were released too.
22862286
self.assertEqual(CountedObject.n_instances, 0)
22872287

2288+
def test_del_pool(self):
2289+
p = self.Pool(1)
2290+
wr = weakref.ref(p)
2291+
del p
2292+
gc.collect()
2293+
self.assertIsNone(wr())
22882294

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

0 commit comments

Comments
 (0)