mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
Merged revisions 78777,78787,78790 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78777 | florent.xicluna | 2010-03-08 00:49:03 +0100 (lun, 08 mar 2010) | 4 lines Backport the Popen.poll() protection from subprocess to multiprocessing. See #1731717. It should fix transient failures on test_multiprocessing. ........ r78787 | florent.xicluna | 2010-03-08 08:21:16 +0100 (lun, 08 mar 2010) | 2 lines Don't fail on a debug() statement, if the worker PID is (still) None. ........ r78790 | florent.xicluna | 2010-03-08 12:01:39 +0100 (lun, 08 mar 2010) | 2 lines On finalize, don't try to join not started process. ........
This commit is contained in:
parent
4886d246a8
commit
998171f0d7
2 changed files with 9 additions and 6 deletions
|
@ -104,7 +104,12 @@ if sys.platform != 'win32':
|
||||||
|
|
||||||
def poll(self, flag=os.WNOHANG):
|
def poll(self, flag=os.WNOHANG):
|
||||||
if self.returncode is None:
|
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 pid == self.pid:
|
||||||
if os.WIFSIGNALED(sts):
|
if os.WIFSIGNALED(sts):
|
||||||
self.returncode = -os.WTERMSIG(sts)
|
self.returncode = -os.WTERMSIG(sts)
|
||||||
|
|
|
@ -448,12 +448,10 @@ class Pool(object):
|
||||||
if pool and hasattr(pool[0], 'terminate'):
|
if pool and hasattr(pool[0], 'terminate'):
|
||||||
debug('joining pool workers')
|
debug('joining pool workers')
|
||||||
for p in pool:
|
for p in pool:
|
||||||
p.join()
|
if p.is_alive():
|
||||||
for w in pool:
|
|
||||||
if w.exitcode is None:
|
|
||||||
# worker has not yet exited
|
# worker has not yet exited
|
||||||
debug('cleaning up worker %d' % w.pid)
|
debug('cleaning up worker %d' % p.pid)
|
||||||
w.join()
|
p.join()
|
||||||
|
|
||||||
#
|
#
|
||||||
# Class whose instances are returned by `Pool.apply_async()`
|
# Class whose instances are returned by `Pool.apply_async()`
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue