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 ulidtko
Recipients ulidtko
Date 2011-03-03.01:32:45
SpamBayes Score 1.3387651e-06
Marked as misclassified No
Message-id <1299115966.12.0.337666295395.issue11380@psf.upfronthosting.co.za>
In-reply-to
Content
The following script fails:

from time import sleep

try:
    while True:
        sleep(0.1)
        print "blah"
except KeyboardInterrupt:
    pass


when being launched with redirections like this:
$ python test.py | tee /dev/null

and the tee process gots killed *before* the python process (by e.g. hitting ^C in most shells). The output is:

close failed in file object destructor:
sys.excepthook is missing
lost sys.stderr

When the python process is SIGINTed prior to the tee process, everything goes as expected: buffered output to stdout gots flushed and seen on the console, the script finishes successfully, with zero exit status, tee finishes too. When the tee receives SIGINT first, and then python, script loses the output and prints the mentioned message. strace shows that python is receiving (but probably not handling properly) "Broken pipe" error in response to write(2):
[pid 17874] write(1, "blah\nblah\nblah\nblah\nblah\nblah\nbl"..., 680) = -1 EPIPE (Broken pipe)
History
Date User Action Args
2011-03-03 01:32:46ulidtkosetrecipients: + ulidtko
2011-03-03 01:32:46ulidtkosetmessageid: <1299115966.12.0.337666295395.issue11380@psf.upfronthosting.co.za>
2011-03-03 01:32:45ulidtkolinkissue11380 messages
2011-03-03 01:32:45ulidtkocreate