Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update start_new_thread() doc
  • Loading branch information
vstinner committed May 28, 2019
commit c92ed35c4d6a3863db56b3bdbe9384e992093035
22 changes: 16 additions & 6 deletions Doc/library/_thread.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,22 @@ This module defines the following constants and functions:

.. function:: start_new_thread(function, args[, kwargs])

Start a new thread and return its identifier. The thread executes the function
*function* with the argument list *args* (which must be a tuple). The optional
*kwargs* argument specifies a dictionary of keyword arguments. When the function
returns, the thread silently exits. When the function terminates with an
unhandled exception, a stack trace is printed and then the thread exits (but
other threads continue to run).
Start a new thread and return its identifier. The thread executes the
function *function* with the argument list *args* (which must be a tuple).
The optional *kwargs* argument specifies a dictionary of keyword arguments.

When the function returns, the thread silently exits.

When the function terminates with an unhandled exception,
:func:`sys.unraisablehook` is called to handle the exception (the *obj*
attribute of the hook is set to *function*). By default, a stack trace is
printed and then the thread exits (but other threads continue to run).

When the function raises a :exc:`SystemExit` exception, it is silently
ignored.

.. versionchanged:: 3.8
:func:`sys.unraisablehook` is now used to handle unhandled exceptions.


.. function:: interrupt_main()
Expand Down
1 change: 1 addition & 0 deletions Modules/_threadmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1002,6 +1002,7 @@ t_bootstrap(void *boot_raw)
res = PyObject_Call(boot->func, boot->args, boot->keyw);
if (res == NULL) {
if (PyErr_ExceptionMatches(PyExc_SystemExit))
/* SystemExit is ignored silently */
PyErr_Clear();
else {
_PyErr_WriteUnraisableMsg("in thread started by", boot->func);
Expand Down