Opened 21 months ago

Closed 9 months ago

#8264 defect closed duplicate (duplicate)

STDLibLoggingObserver doesn't log traceback from unhandled Deferred errors

Reported by: Glyph Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:
Author:

Description

This program:

#!/usr/bin/env python2.7

import logging
from twisted import logger

# Route Python's logging somewhere sensible.
logging.basicConfig(level=logging.DEBUG)

# Comment out this line to see an actual, useful traceback.
logger.globalLogBeginner.beginLoggingTo([logger.STDLibLogObserver()])

from twisted.internet.defer import fail

def unhandled_error():
    try:
        1/0
    except ZeroDivisionError:
        return fail()

unhandled_error()

produces this output:

CRITICAL:twisted:Unhandled error in Deferred:
CRITICAL:twisted:

This is a problem, because it should be producing a traceback to help diagnose the error.

I believe the root cause may be even simpler, which is that STDLibLoggingObserver can't handle None format strings, and that's what the unhandled-error logging code in Deferred.__del__ is emitting.

Change History (1)

comment:1 Changed 9 months ago by Glyph

Resolution: duplicate
Status: newclosed

This was a duplicate of #8037.

Note: See TracTickets for help on using tickets.