[Twisted-Python] Twisted debugging support
James Y Knight
foom at fuhm.net
Wed Jul 28 15:48:49 EDT 2004
So, I propose to make the following change. I see no reason to destroy
any hope of proper debugging support by doing a callLater of set_trace,
for one. For two: control-c *really* ought to break into the debugger.
Is there an actual reason why the previous code did
reactor.callLater(0, pdb.set_trace)??
James
Index: twisted/application/app.py
===================================================================
--- twisted/application/app.py (revision 11112)
+++ twisted/application/app.py (working copy)
@@ -84,7 +84,8 @@
sys.stdout = oldstdout
sys.stderr = oldstderr
if runtime.platformType == 'posix':
- signal.signal(signal.SIGUSR2, lambda *args:
reactor.callLater(0, pdb.set_trace))
+ signal.signal(signal.SIGUSR2, lambda *args:
pdb.set_trace())
+ signal.signal(signal.SIGINT, lambda *args:
pdb.set_trace())
pdb.runcall(reactor.run)
else:
reactor.run()
Index: twisted/internet/default.py
===================================================================
--- twisted/internet/default.py (revision 11112)
+++ twisted/internet/default.py (working copy)
@@ -90,7 +90,9 @@
def _handleSignals(self):
"""Install the signal handlers for the Twisted event loop."""
import signal
- signal.signal(signal.SIGINT, self.sigInt)
+ if signal.getsignal(signal.SIGINT) ==
signal.default_int_handler:
+ # only handle if there isn't already a handler, e.g. for
Pdb.
+ signal.signal(signal.SIGINT, self.sigInt)
signal.signal(signal.SIGTERM, self.sigTerm)
# Catch Ctrl-Break in windows (only available in Python 2.2
and up)
More information about the Twisted-Python
mailing list