[Twisted-Python] How do I get the reactor to stop on an exception
I'm running a rather involved simulation using twisted, and it would be preferable if I could get the reactor to just drop me into the interpreter on any exception so I could examine the current state of things. I set os.environ['PYTHONINSPECT'] = '1', but the reactor seems to trap any exceptions and just merrily carry on - logging my tracebacks to a file, but continuing to run - modifying the current state of things and making it harder to track down bugs. Is there an easy way to prevent the reactor from trapping exceptions? Thanks, Gerrat
On Tue, 3 Jun 2008 17:23:57 -0400, Gerrat Rickert <grickert@coldstorage.com> wrote:
I'm running a rather involved simulation using twisted, and it would be preferable if I could get the reactor to just drop me into the interpreter on any exception so I could examine the current state of things.
Unit tests are a great way to squash bugs quickly and permanently.
I set os.environ['PYTHONINSPECT'] = '1', but the reactor seems to trap any exceptions and just merrily carry on - logging my tracebacks to a file, but continuing to run - modifying the current state of things and making it harder to track down bugs.
Is there an easy way to prevent the reactor from trapping exceptions?
No, there's not. However, you might be interested in the --debug option to twistd, which will drop you into pdb when an unhandled exception is raised. Jean-Paul
I'm running a rather involved simulation using twisted, and it would be preferable if I could get the reactor to just drop me into the interpreter on any exception so I could examine the current state of things.
When using twistd or trial, you can simply use the debug command-line option for that (-b). Without those, twisted.python.failure.setDebugMode(True) or something, I forget the exact invocation. Both of these only go into debugger on Failure creation, but that's essentially any exception that goes into a Deferred or into the logging system, so virtually any exception you're likely to care about.
participants (3)
-
Gerrat Rickert -
Itamar Shtull-Trauring -
Jean-Paul Calderone