diff options
Diffstat (limited to 'Lib/multiprocessing')
-rw-r--r-- | Lib/multiprocessing/forking.py | 7 | ||||
-rw-r--r-- | Lib/multiprocessing/pool.py | 8 |
2 files changed, 9 insertions, 6 deletions
diff --git a/Lib/multiprocessing/forking.py b/Lib/multiprocessing/forking.py index 3c0f568..5d66fa3 100644 --- a/Lib/multiprocessing/forking.py +++ b/Lib/multiprocessing/forking.py @@ -104,7 +104,12 @@ if sys.platform != 'win32': def poll(self, flag=os.WNOHANG): if self.returncode is None: - pid, sts = os.waitpid(self.pid, flag) + try: + pid, sts = os.waitpid(self.pid, flag) + except os.error: + # Child process not yet created. See #1731717 + # e.errno == errno.ECHILD == 10 + return None if pid == self.pid: if os.WIFSIGNALED(sts): self.returncode = -os.WTERMSIG(sts) diff --git a/Lib/multiprocessing/pool.py b/Lib/multiprocessing/pool.py index 6271b86..d2b8dd1 100644 --- a/Lib/multiprocessing/pool.py +++ b/Lib/multiprocessing/pool.py @@ -448,12 +448,10 @@ class Pool(object): if pool and hasattr(pool[0], 'terminate'): debug('joining pool workers') for p in pool: - p.join() - for w in pool: - if w.exitcode is None: + if p.is_alive(): # worker has not yet exited - debug('cleaning up worker %d' % w.pid) - w.join() + debug('cleaning up worker %d' % p.pid) + p.join() # # Class whose instances are returned by `Pool.apply_async()` |