diff options
author | Antoine Pitrou <antoine@python.org> | 2021-03-11 22:35:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-11 22:35:45 (GMT) |
commit | ba251c2ae6654bfc8abd9d886b219698ad34ac3c (patch) | |
tree | e536a5ba9f661c806ffaa507e2ca4cf1be551b5a /Doc/library | |
parent | b4fc44bb2d209182390b4f9fdf074a46b0165a2f (diff) | |
download | cpython-ba251c2ae6654bfc8abd9d886b219698ad34ac3c.zip cpython-ba251c2ae6654bfc8abd9d886b219698ad34ac3c.tar.gz cpython-ba251c2ae6654bfc8abd9d886b219698ad34ac3c.tar.bz2 |
bpo-43356: Allow passing a signal number to interrupt_main() (GH-24755)
Also introduce a new C API ``PyErr_SetInterruptEx(int signum)``.
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/_thread.rst | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/Doc/library/_thread.rst b/Doc/library/_thread.rst index bd653ab..1e6452b 100644 --- a/Doc/library/_thread.rst +++ b/Doc/library/_thread.rst @@ -61,15 +61,27 @@ This module defines the following constants and functions: :func:`sys.unraisablehook` is now used to handle unhandled exceptions. -.. function:: interrupt_main() +.. function:: interrupt_main(signum=signal.SIGINT, /) - Simulate the effect of a :data:`signal.SIGINT` signal arriving in the main - thread. A thread can use this function to interrupt the main thread. + Simulate the effect of a signal arriving in the main thread. + A thread can use this function to interrupt the main thread, though + there is no guarantee that the interruption will happen immediately. - If :data:`signal.SIGINT` isn't handled by Python (it was set to + If given, *signum* is the number of the signal to simulate. + If *signum* is not given, :data:`signal.SIGINT` is simulated. + + If the given signal isn't handled by Python (it was set to :data:`signal.SIG_DFL` or :data:`signal.SIG_IGN`), this function does nothing. + .. versionchanged:: 3.10 + The *signum* argument is added to customize the signal number. + + .. note:: + This does not emit the corresponding signal but schedules a call to + the associated handler (if it exists). + If you want to truly emit the signal, use :func:`signal.raise_signal`. + .. function:: exit() |