[Twisted-Python] How to show traceback of "Unhandled error"?
jlitzingerdev at gmail.com
Fri May 18 22:37:51 MDT 2018
> Try this:
> from twisted.logger import globalLogBeginner, textFileLogObserver
> from twisted.internet.defer import Deferred
> import sys
> def raiseErr(what):
> raise Exception(what)
> d = Deferred()
FWIW, I had some trouble (nothing printed) with Python 3.6 using the
example above. Python 2 was fine, and PYTHONUNBUFFERED (or flush) didn't help.
I'll follow up should I figure out what's going on. I had success on
Python3 with the STDLibLogObserver...which doesn't make any immediate
sense other than something flushing related.
> The associated PR needs a careful review to ensure its handling of unicode is correct. Any takers?
Agree, given the recent tickets/regressions related to Unicode I'm going
to go back through my PR. If it disappears from review...I found
> > # how to show the traceback without manually adding an errback at the end?
> > # adding at the *end* of a deferred is hard as we don't know when the
> > client stops adding callbacks.
I've also found this advice from Jean-Paul very helpful:
You'll get more detailed info:
CRITICAL:twisted:Unhandled error in Deferred:
CRITICAL:twisted:(debug: C: Deferred was created:
C: File "foo.py", line 15, in <module>
C: d = defer.Deferred()
I: First Invoker was:
I: File "foo.py", line 17, in <module>
Traceback (most recent call last):
File "/home/jlitzing/dev/twisted/twisted-fork/src/twisted/internet/defer.py", line 653, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "foo.py", line 13, in raiseErr
More information about the Twisted-Python