New submission from ulidtko <ulid...@gmail.com>:

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)

----------
components: IO
messages: 129930
nosy: ulidtko
priority: normal
severity: normal
status: open
title: "close failed in file object destructor" when "Broken pipe" happens on 
stdout
type: behavior
versions: Python 2.7

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue11380>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to