[issue7932] print statement delayed IOError when stdout has been closed

2014-06-08 Thread tholzer
tholzer added the comment: It's still a problem in Python 2.7: python -c 'import sys; print >> sys.stdout, "x"' 1>&- ; echo $? close failed in file object destructor: sys.excepthook is missing lost sys.stderr 0 But feel free to close as "won

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-29 Thread tholzer
tholzer added the comment: And a test case for smtplib: import threading import signal import os import smtplib def go(): running = True pid = os.getpid() def killer(): while running: os.kill(pid, signal.SIGINT) signal.signal(signal.SIGINT, lambda x,y

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-29 Thread tholzer
Changes by tholzer : Removed file: http://bugs.python.org/file35359/socket_2.7.3_eintr_patch.py ___ Python tracker <http://bugs.python.org/issue20611> ___ ___ Python-bug

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-29 Thread tholzer
tholzer added the comment: Oops, I missed a break statement at the end of socket_2.7.3_eintr_patch.py. I've fixed this now in the attached patch. @meishao Could you please also update your socket_2_7_2_patch.py and add the missing break statement ? -- Added file:

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-25 Thread tholzer
Changes by tholzer : Removed file: http://bugs.python.org/file35360/socketmodule_2.7.6_eintr_patch.c ___ Python tracker <http://bugs.python.org/issue20611> ___ ___ Pytho

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-25 Thread tholzer
Changes by tholzer : Added file: http://bugs.python.org/file35361/socketmodule_2.7.6_eintr_patch.c ___ Python tracker <http://bugs.python.org/issue20611> ___ ___ Pytho

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-25 Thread tholzer
tholzer added the comment: I've also attached a potential patch for the C module Modules/socketmodule.c inside internal_connect(). A few notes: This seems to work both without time-out and with time-out sockets (non-blocking). One concern would be a signal storm prolonging the oper

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-25 Thread tholzer
tholzer added the comment: No problem, I've attached a patch for socket.py for Python 2.7.3. A few notes: getaddrinfo (and gethostbyname, etc.) are already immune to this bug, so I've just fixed the connect() call. The socket does need to be closed after EINTR, otherwise a EINPROG

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-19 Thread tholzer
tholzer added the comment: Here is a reproducible test case: import threading import signal import os import httplib def killer(): while 1: os.kill(os.getpid(), signal.SIGINT) def go(): signal.signal(signal.SIGINT, lambda x,y: None) thread = threading.Thread(target=killer

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-19 Thread tholzer
Changes by tholzer : Added file: http://bugs.python.org/file35297/httplib_2.7.3_eintr_patch.py ___ Python tracker <http://bugs.python.org/issue20611> ___ ___ Python-bug

[issue20611] socket.create_connection() doesn't handle EINTR properly

2014-05-19 Thread tholzer
tholzer added the comment: We encountered the same problem, this is in the context of using PyQt (specifically QProcess) or twisted. They both rely on SIGCHLD for their notification framework. I've attached a httplib EINTR patch for 2.6.4 & 2.7.3. -- nosy: +tholzer Added f

[issue21058] tempfile.NamedTemporaryFile leaks file descriptor when fdopen fails

2014-03-24 Thread tholzer
New submission from tholzer: The NamedTemporaryFile inside the standard tempfile library leaks an open file descriptor when fdopen fails. Test case: # ulimit -SHn 50 # python test1.py from tempfile import NamedTemporaryFile while 1: try: NamedTemporaryFile(mode='x')

[issue7932] print statement delayed IOError when stdout has been closed

2010-02-15 Thread tholzer
tholzer added the comment: This is not quite correct: The following 2 lines fail as expected (unbuffered): python -u -c 'import sys; print >> sys.stdout, "x"' 1>&- ; echo $? python -u -c 'import sys; print >> sys.stderr, "x"' 2

[issue7932] print statement delayed IOError when stdout has been closed

2010-02-14 Thread tholzer
New submission from tholzer : When printing to a closed stdout file descriptor, the print statement only raises an IOError at character 8192. The expected behaviour is that IOError gets raised immediately (i.e. on the first character). Compare this behaviour to writing to a closed sys.stderr