You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Collect timestamps on most exceptions for optional display on tracebacks. #132502
Why? to make debugging what happened in async servers with lots of exception groups and exceptions easier. Event timestamps reported on everything when emitting exception groups containing tracebacks often with their own nested causes would allow some semblance of order to be more readily understood and correlated with other parts of the distributed system.
Semi related to the rationale behind https://peps.python.org/pep-0785/ to make events in exception groups easier - when you've got an error report involving exception groups, potentially nested from async sources, reading that to understand what happened when is hard. But with timestamps on the exceptions rendered with the tracebacks you can better understand the ordering of events.
I've got a working implementation over in a PR 129337. It's time to file the tracking issue and polish things up for discussion.
While this gets considered for CPython core, there's already a PyPI package that does this today: dttb.
One line to enable:
importdttbdttb.apply()
It patches both sys.excepthook and threading.excepthook to include timestamps on every traceback, supports timezone configuration and custom callbacks. Might be useful to folks who need this now, and could also serve as a reference for what the CPython implementation might look like.
dttb and excepthook based things do not capture timestamps at the time of raise or handle timing of all exceptions within a chain or within ExceptionGroups.
Activity
rocky-d commentedon Mar 12, 2026
While this gets considered for CPython core, there's already a PyPI package that does this today: dttb.
One line to enable:
It patches both
sys.excepthookandthreading.excepthookto include timestamps on every traceback, supports timezone configuration and custom callbacks. Might be useful to folks who need this now, and could also serve as a reference for what the CPython implementation might look like.gpshead commentedon Apr 14, 2026
dttband excepthook based things do not capture timestamps at the time of raise or handle timing of all exceptions within a chain or within ExceptionGroups.gpshead commentedon Apr 14, 2026
discussion live in https://discuss.python.org/t/pep-830-add-timestamps-to-exceptions-and-tracebacks/106942