Message129930
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) |
|
Date |
User |
Action |
Args |
2011-03-03 01:32:46 | ulidtko | set | recipients:
+ ulidtko |
2011-03-03 01:32:46 | ulidtko | set | messageid: <1299115966.12.0.337666295395.issue11380@psf.upfronthosting.co.za> |
2011-03-03 01:32:45 | ulidtko | link | issue11380 messages |
2011-03-03 01:32:45 | ulidtko | create | |
|