[issue36666] threading.Thread should have way to catch an exception thrown within

Mark Borgerding report at bugs.python.org
Tue Oct 29 13:56:00 EDT 2019


Mark Borgerding <mborgerd at gmail.com> added the comment:

I'm not trying to disrespect anyone: not users nor certainly Python developers.  I have loved Python since I learned it in 2001.  I was merely trying to respond to what seemed like an automatic rejection of changing legacy behavior.  I certainly agree changes to default behavior should not be made lightly, but sometimes they *should* be made.

This may be such a case:
a) A user writing a thread function either consciously thinks about exceptions while they write function or they do not.  Sure, we should always do the former; just like we should always eat our veggies and get lots of exercise, but ....
b) If they *do* think about exceptions, they will either
b.1) write exception handlers within that function, or
b.2) rely on default behavior that simply prints out the exception string to stderr and lets the thread quietly die.
c) If they did not explicitly think about exceptions while they wrote the function, they may have in the back of their mind the reasonable expectation that an exception will not be ignored.

Changing `join()` to propagate unhandled exceptions would admittedly break b.2 code, but provides absolution for all sinners who have written case c.

This is what I meant by, "I suspect there is more code that will be fixed by such a change than broken."

I'll confess I only just now became aware of `threading.excepthook` added in python 3.8.  Does it change this problem?

----------
Added file: https://bugs.python.org/file48686/ignored_thread_exc.py

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


More information about the Python-bugs-list mailing list