> In that past, there have been a few times where it would have been > very convenient to terminate/signal another thread by posting an > exception to it. Using KeyboardInterrupt to do so is okay, although > it seems like something of a kludge. This gets into the general discussion about whether threads should be stoppable. Also, this mechanism can *only* interrupt the main thread. (That's even true of the more generalized version you were thinking of.) > Code that gives special status to KeyboardInterrupt doesn't worry me > at all. What I am wary of is code that is not written to be > exception safe in the presence of unexpected exceptions (not just > asynchronous ones). The example I was working on yesterday involved > KeyboardInterrupts generated from an SSL socket in httplib's SSL > readline method. A keyboard interrupt will result in data read from > the socket and then stored in a local variable to be lost. Of > course, this error wasn't very likely before I patched the SSL > module to check for interrupts, but that is beside the point. That's a problem that'll always remain. --Guido van Rossum (home page: http://www.python.org/~guido/)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4