On Sep 24, 2015, at 9:30 PM, Timothy Allen <Timothy.Allen@optiver.com.au> wrote:
The other day I was experimenting with the inlineCallbacks decorator in Twisted 15.4, and occasionally when I'd typo a variable name or similar, I'd get an "unhandled error" in the log without a traceback, which was rather unhelpful. Eventually, I managed to produce the following test-case:
https://gist.github.com/OptiverTimAll/43263a7a4cf5a298e8f5
If I run it as-is, I get the following unhelpful output:
CRITICAL:twisted:Unhandled error in Deferred: CRITICAL:twisted:
If I comment out the line that redirects Twisted's logging to the standard library's logging system, I get much more helpful output:
Unhandled error in Deferred:
Traceback (most recent call last): File "./ic-test.py", line 20, in <module> bogus_callback() File "/home/timall/.virtualenvs/txfuse/lib/python2.7/site-packages/twisted/internet/defer.py", line 1274, in unwindGenerator return _inlineCallbacks(None, gen, Deferred()) --- <exception caught here> --- File "/home/timall/.virtualenvs/txfuse/lib/python2.7/site-packages/twisted/internet/defer.py", line 1128, in _inlineCallbacks result = g.send(result) File "./ic-test.py", line 17, in bogus_callback yield does_not_exist() exceptions.NameError: global name 'does_not_exist' is not defined
I expected that changing the destination of log messages wouldn't change their content, but apparently I was wrong. I got the incantation for re-routing Twisted's logging system into the Python one by stitching together code-snippets from http://twistedmatrix.com/documents/current/core/howto/logger.html#starting-t... Is there some better way, or some other thing I should be doing?
Your setup sounds basically correct, and I think you've just discovered a bug here. Could you report it in the tracker? I haven't fully diagnosed it yet, but in attempting to do so, I've found a few other odd edge cases in traceback printing. -glyph