[issue10478] Ctrl-C locks up the interpreter
Antoine Pitrou
report at bugs.python.org
Sun Nov 21 17:15:39 CET 2010
Antoine Pitrou <pitrou at free.fr> added the comment:
Wow. The lock is precisely there so that the buffered object doesn't have to be MT-safe or reentrant. It doesn't seem reasonable to attempt to restore the file to a "stable" state in the middle of an inner routine.
Also, the outer TextIOWrapper (we're talking about sys.stdout here) is not designed to MT-safe at all and is probably in an inconsistent state itself.
I would rather detect that the lock is already taken by the current thread and raise a RuntimeError. I don't think it's a good idea to do buffered I/O in a signal handler. Unbuffered I/O probably works.
(in a more sophisticated version, we could store pending writes so that they get committed at the end of the currently executing write)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue10478>
_______________________________________
More information about the Python-bugs-list
mailing list