[issue1230540] sys.excepthook doesn't work in threads

Andrey Vlasovskikh report at bugs.python.org
Wed Aug 1 18:08:24 EDT 2018


Andrey Vlasovskikh <andrey.vlasovskikh at gmail.com> added the comment:

I've added a PR with a patch I developed during the EuroPython 2018 sprint.

I've fixed this issue in a way that is more or less consistent with how '_thread' threads interact with sys.excepthook, but I haven't added the log line they print to sys.stderr about an unhandled exception in a thread:

    Unhandled exception in thread started by <function <lambda> at 0x108c840d0>

I can add these messages if they are needed.

I'd like to mention the issue I discussed with Victor Stinner at the sprints (adding Victor to the nosy list as he requested). The fix could possibly break the de facto contract that has been there for ages that 'theading' threads don't invoke sys.excepthook on uncaught exceptions.

If the fact that sys.execepthook doesn't work with threading is considered a feature, then an alternative solution could be a new threading-specific hook: threading.excepthook.

----------
nosy: +vlasovskikh, vstinner

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue1230540>
_______________________________________


More information about the Python-bugs-list mailing list