Issue #13812: When a multiprocessing Process child raises an exception, flush stderr after printing the exception traceback.

This commit is contained in:
Antoine Pitrou 2012-01-27 10:53:35 +01:00
commit 2d843d2520
4 changed files with 30 additions and 5 deletions

View file

@ -129,8 +129,6 @@ if sys.platform != 'win32':
import random
random.seed()
code = process_obj._bootstrap()
sys.stdout.flush()
sys.stderr.flush()
os._exit(code)
# `w` will be closed when the child exits, at which point `r`

View file

@ -291,16 +291,17 @@ class Process(object):
exitcode = e.args[0]
else:
sys.stderr.write(e.args[0] + '\n')
sys.stderr.flush()
exitcode = 1
except:
exitcode = 1
import traceback
sys.stderr.write('Process %s:\n' % self.name)
sys.stderr.flush()
traceback.print_exc()
finally:
util.info('process exiting with exitcode %d' % exitcode)
sys.stdout.flush()
sys.stderr.flush()
util.info('process exiting with exitcode %d' % exitcode)
return exitcode
#