[Twisted-Python] Exit all threads upon KeyboardInterrupt

Dustin J. Mitchell dustin at v.igoro.us
Tue Jan 14 07:27:23 MST 2014


There are two things wrong with your scenario.

First, in any production or production-ready environment, your
software needs to correctly handle stuck TCP connections.  With the
proliferation of "smart" network equipment (session-tracking
firewalls, etc.), this is much more common than it was five or ten
years ago.  Some DBAPI backends are better about this than others -
for example, MySQL-Python gets it right, but PyMySQL does not.

Second, this has nothing whatsoever to do with whether the I/O is
blocking or not.  Twisted apps can and, believe me from experience, do
suffer from stuck TCP connections.  Sure, the wasted resources in this
case are smaller (just a file descriptor, not a thread), but the user
experience is the same (part of the application hangs irreversibly).
In fact, this is about the only thing the manhole is used for at
Mozilla: running `os.close` on stuck fd's.

Dustin




More information about the Twisted-Python mailing list