[Twisted-Python] Anyone seeing hanging of Twisted HTTPS servers?

Mike C. Fletcher mcfletch at rogers.com
Thu May 19 14:57:44 EDT 2005


James Y Knight wrote:
...

> I think it's probably more likely that it's not hanging in C code at
> all, but in a bit of application python code. What I'd do is add a
> "watchdog" timer, something like this. Of course, this won't work if
> it's blocking in a C call somewhere because the python signal handler
> won't be called until the C call returns. But even that might give you
> some useful information on what the problem is.
>
> import signal, pdb, sys
> from twisted.internet import task
>
> def timeout(*args):
> sys.stderr.write("SIGALRM timeout, breaking into debugger.\n")
> import pdb; pdb.set_trace()
>
> signal.signal(signal.SIGALRM, timeout)
>
> task.LoopingCall(signal.alarm, 10).start(1)

That's really nice. However, it seems that the alarm handler drops into
the database thread, rather than the foreground thread. Still, it does
make it possible to simply log the heck out of everything and force an
exit of the whole application to see where in the log it's stopping.

Thanks,
Mike

-- 
________________________________________________
  Mike C. Fletcher
  Designer, VR Plumber, Coder
  http://www.vrplumber.com
  http://blog.vrplumber.com





More information about the Twisted-Python mailing list