From 007f1347fa14eb2dcf58fdc29bac75e8ca716778 Mon Sep 17 00:00:00 2001 From: Dustin Oprea Date: Sun, 12 Feb 2017 17:54:57 -0500 Subject: [PATCH] bpo-19675: Fixes pool cleanup issue - http://bugs.python.org/issue19675 --- Lib/multiprocessing/pool.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py index ffdf42614d59eb..cba61103b9d849 100644 --- a/Lib/multiprocessing/pool.py +++ b/Lib/multiprocessing/pool.py @@ -220,19 +220,31 @@ def _repopulate_pool(self): """Bring the number of pool processes up to the specified number, for use after reaping workers which have exited. """ - for i in range(self._processes - len(self._pool)): - w = self.Process(target=worker, - args=(self._inqueue, self._outqueue, - self._initializer, - self._initargs, self._maxtasksperchild, - self._wrap_exception) - ) - self._pool.append(w) - w.name = w.name.replace('Process', 'PoolWorker') - w.daemon = True - w.start() - util.debug('added worker') + try: + for i in range(self._processes - len(self._pool)): + w = self.Process(target=worker, + args=(self._inqueue, self._outqueue, + self._initializer, + self._initargs, self._maxtasksperchild) + ) + self._pool.append(w) + w.name = w.name.replace('Process', 'PoolWorker') + w.daemon = True + w.start() + util.debug('added worker') + except: + util.debug("Process creation error. Cleaning-up (%d) workers." % (len(self._pool))) + + for process in self._pool: + if process.is_alive() is False: + continue + + process.terminate() + process.join() + util.debug("Processing cleaning-up. Bubbling error.") + raise + def _maintain_pool(self): """Clean up any exited workers and start replacements for them. """ pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy