[Twisted-Python] Exit all threads upon KeyboardInterrupt

Dustin J. Mitchell dustin at v.igoro.us
Tue Jan 14 12:37:50 MST 2014


You're absolutely right.  I wasn't arguing with you, but with JP :)

Dustin

On Tue, Jan 14, 2014 at 2:06 PM, Glyph Lefkowitz
<glyph at twistedmatrix.com> wrote:
> On Jan 14, 2014, at 6:27 AM, Dustin J. Mitchell <dustin at v.igoro.us> wrote:
>
> 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.
>
>
> The lack of 'abortConnection' was a pretty serious design flaw in Twisted's
> transport interface initially, but that's been resolved for quite some time
> now.  It should be possible to handle this at the application level on a
> per-connection basis quite gracefully now.
>
> I mean, your point is correct; you can certainly have "stuck" event sources
> in Twisted too, without any threads.  And without any intervention it
> results in exactly the same bad user experience.  I've certainly seen it
> myself.
>
> However, intervention is easier than with a stuck thread.  You can't
> interrupt an arbitrary thread; you don't know and can't tell what it is
> doing without pretty invasive debugging instrumentation.  And, as you note,
> even before the advent of abortConnection, an os.close() could easily deal
> with a stuck async FD on a per-connection basis, without need to bring the
> entire process down.
>
> Finally, we have abortConnection now, so my main point stands; the point was
> not "never call os._exit" but rather "if you have to call os._exit, there's
> a bug".  The same is true here: if you have to manhole into your server to
> call os.close, there's a bug in your application where it's not timing
> something out and freeing a resource it otherwise could be freeing.
>
> Unless your contention is that there are no bugs in buildbot? ;-)
>
> -glyph
>
>
> _______________________________________________
> Twisted-Python mailing list
> Twisted-Python at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
>




More information about the Twisted-Python mailing list