Archives May 19, 2005

Neat debugging trick from James Knight (Finding out what's hanging in your Twisted application...)


In response to my queries about how to catch a hanging application, James posted this wonderful little snippet of code:
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)

The reason that works is that the alarm call cancels all previous alarm ...

Continue reading

Previous day

May 18, 2005

Next day

May 20, 2005

Archives