Author vstinner
Recipients vstinner
Date 2019-05-28.10:15:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1559038510.38.0.6664392813.issue37076@roundup.psfhosted.org>
In-reply-to
Content
Python 3.8 now has 3 hooks for uncaught exceptions:

* sys.excepthook()
* sys.unraisablehook()
* threading.excepthook()

_thread.start_new_thread() calls none of these hooks, but directly logs the exception.

I propose to modify it to reuse sys.unraisablehook(): see attached PR.

--

Using threading.excepthook() would be another option, but _thread.start_new_thread() is usually wrapped in threading.Thread.run() which already uses threading.excepthook(). It might be surprising to see two bugs from the same thread using threading.excepthook().

Moreover, right now, _thread is the "low-level" API to access threads: it doesn't acces threading. I'm not comfortable by adding an inter-dependency between _thread (low-level) and threading (high-level).

If threading.Thread.run() is correctly written, it should not raise an exception. In the worst case, threading.excepthook should handle the exception. _thread.start_new_thread() should never get an exception raised by threading if threading.excepthook does correctly its job.
History
Date User Action Args
2019-05-28 10:15:10vstinnersetrecipients: + vstinner
2019-05-28 10:15:10vstinnersetmessageid: <1559038510.38.0.6664392813.issue37076@roundup.psfhosted.org>
2019-05-28 10:15:10vstinnerlinkissue37076 messages
2019-05-28 10:15:10vstinnercreate