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

Antoine Pitrou report at bugs.python.org
Sat May 25 17:19:46 EDT 2019


Antoine Pitrou <pitrou at free.fr> added the comment:

Le 25/05/2019 à 23:09, STINNER Victor a écrit :
> 
> I don't see the relationship between the API (signature) and the ability to set a per-thread hook.
> 
> I'm not convinced that a per-thread hook is needed.

Indeed, if you write your own Thread class, you can add a try...except
in the Thread.run() method.  You don't need a dedicated
Thread.excepthook() method.

The only way a per-thread hook could be useful is if you could set it
*outside* of the Thread class (so not as a method), so that one can e.g.
catch / report exceptions raised in threads launches by third-party
libraries.

----------

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


More information about the Python-bugs-list mailing list