[New-bugs-announce] [issue11380] "close failed in file object destructor" when "Broken pipe" happens on stdout
ulidtko
report at bugs.python.org
Thu Mar 3 02:32:46 CET 2011
New submission from ulidtko <ulidtko at 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 <report at bugs.python.org>
<http://bugs.python.org/issue11380>
_______________________________________
More information about the New-bugs-announce
mailing list