Robert Collins added the comment:
@zzeeek
For Python 3 pipeline tools you need something like this:
try:
<all your stuff>
finally:
try:
sys.stdout.flush()
finally:
try:
sys.stdout.close()
finally:
try:
sys.stderr.flush()
finally:
sys.stderr.close()
This will:
- capture any exceptions *you've* raised as the context for the errors raised
in this handler
- expose any exceptions generated during this thing itself
- prevent the interpreter dying during shutdown in flush_std_files by closing
the files (you can't easily wipe out the pending writes that have failed)
You could alternatively reopen stdout and stderr on the same fds, giving you
new buffers with no pending writes. Anyhow - the key thing is:
- ensure that at shutdown, there are no pending writes for the interpreter
lifecycle to flush, and you won't hit this bug.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue11380>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com