summaryrefslogtreecommitdiffstats
path: root/Lib/multiprocessing
diff options
context:
space:
mode:
authorJulien Palard <julien@palard.fr>2018-11-04 22:40:32 (GMT)
committerGitHub <noreply@github.com>2018-11-04 22:40:32 (GMT)
commit5d236cafd7126e640fb25541fcc7e0a494450143 (patch)
treef8b8e98702fc0e4e661d275309652f6fd7546fcc /Lib/multiprocessing
parentb4db249c9544fc4425c32feb86d610f3224ca3d8 (diff)
downloadcpython-5d236cafd7126e640fb25541fcc7e0a494450143.zip
cpython-5d236cafd7126e640fb25541fcc7e0a494450143.tar.gz
cpython-5d236cafd7126e640fb25541fcc7e0a494450143.tar.bz2
bpo-19675: Terminate processes if construction of a pool is failing. (GH-5614)
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r--Lib/multiprocessing/pool.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py
index 574b5db..7a6d014 100644
--- a/Lib/multiprocessing/pool.py
+++ b/Lib/multiprocessing/pool.py
@@ -174,7 +174,15 @@ class Pool(object):
self._processes = processes
self._pool = []
- self._repopulate_pool()
+ try:
+ self._repopulate_pool()
+ except Exception:
+ for p in self._pool:
+ if p.exitcode is None:
+ p.terminate()
+ for p in self._pool:
+ p.join()
+ raise
self._worker_handler = threading.Thread(
target=Pool._handle_workers,
@@ -251,10 +259,10 @@ class Pool(object):
initargs, maxtasksperchild,
wrap_exception)
)
- pool.append(w)
w.name = w.name.replace('Process', 'PoolWorker')
w.daemon = True
w.start()
+ pool.append(w)
util.debug('added worker')
@staticmethod