[issue13812] multiprocessing package doesn't flush stderr on child exception

Charles-François Natali report at bugs.python.org
Tue Jan 24 10:07:40 CET 2012


Charles-François Natali <neologix at free.fr> added the comment:

> I propose applying the following patch.

The test looks good to me (except we don't remove TESTFN explicitely,
but I'm not sure it's really necessary).

As for the patch, couldn't we put all the file stream flushing in one place?

stdout and stderr are already flushed on Unix (which explains why this
only happens on Windows: the libc puts non-tty streams in _IOFBF, so
this wouldn't work without explicit flushing neither).

Lib/multiprocessing/forking.py:Popen.__init__:
           code = process_obj._bootstrap()
           sys.stdout.flush()
           sys.stderr.flush()
           os._exit(code)

Also, there's already a flush() a couple lines above (in _bootstrap):
           sys.stderr.write(e.args[0] + '\n')
           sys.stderr.flush()

So I'd suggest to just put:

           sys.stdout.flush()
           sys.stderr.flush()

At the end of _bootstrap, and remove the flushing done by
Popen.__init__ on Unix.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13812>
_______________________________________


More information about the Python-bugs-list mailing list