This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author rbcollins
Recipients Christopher.Heiny, Jeremy.Fishman, daumiller, flox, ncoghlan, pitrou, rbcollins, terry.reedy, ulidtko, zzzeek
Date 2015-08-14.10:46:31
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1439549191.91.0.339917662802.issue11380@psf.upfronthosting.co.za>
In-reply-to
Content
@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.
History
Date User Action Args
2015-08-14 10:46:31rbcollinssetrecipients: + rbcollins, terry.reedy, ncoghlan, pitrou, zzzeek, flox, ulidtko, Jeremy.Fishman, daumiller, Christopher.Heiny
2015-08-14 10:46:31rbcollinssetmessageid: <1439549191.91.0.339917662802.issue11380@psf.upfronthosting.co.za>
2015-08-14 10:46:31rbcollinslinkissue11380 messages
2015-08-14 10:46:31rbcollinscreate