Issue 751916: Handle keyboard interrupts in SSL module (original) (raw)

As of Python 2.3 beta 1 (and current CVS), the SSL module does not check to see if a keyboard interrupt occurred after waiting on connections, reads, and writes. This results in long delays (seconds or even minutes) before the KeyboardInterrupt is finally raised, causing problematic pauses for interactive processes. This does not happen in Python 2.2.2, though I have not looked into what has changed.

My next step is to look into httplib, the use-case that brought this to my attention, since some of the buffering code is not exception safe. i.e., a KeyboardInterrupt can cause data to be lost on subsequent reads. I suspect that it is also possible to lose data on due to socket timeouts as well, so I consider this issue a distinct bug.

I did not include a new unit test, since it is a little tricky to produce. It requires a large SSL transfer and a network timing-sensitive threshold test to detect.

Also included in the attached patch are some error handling fixes and cleanups related to time-out operations that I happened to notice. This module deserves more attention, since the timeout changes don't look like they were integrated as carefully as they could have been and other similar errors are possible.