[issue14456] Relation between threads and signals unclear
New submission from Sven Marnach <sven@marnach.net>: The documentation of the 'signal' module states on the one hand [T]he main thread will be the only one to receive signals (this is enforced by the Python signal module, even if the underlying thread implementation supports sending signals to individual threads). On the other hand, it provides the function 'pthread_kill()': Send the signal signum to the thread thread_id, another thread in the same process as the caller. The signal is asynchronously directed to thread. These two passages are in contradiction to each other. The documentation also states that only the main thread can set signal handlers -- if this is true, it is utterly unclear how sending signals to other threads is useful. Probably the documentation wasn't fully updated when the above function was introduced. ---------- assignee: docs@python components: Documentation messages: 157156 nosy: docs@python, smarnach priority: normal severity: normal status: open title: Relation between threads and signals unclear versions: Python 3.3 _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14456> _______________________________________
Sven Marnach <sven@marnach.net> added the comment: For reference: the functions 'pthread_kill()' etc. were intrduced in issue8407. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14456> _______________________________________
STINNER Victor <victor.stinner@gmail.com> added the comment:
These two passages are in contradiction to each other.
By default, a thread signal can receive any signal and the signal handler implemented in C will be called in the context of the thread. CPython ensures that a signal handler implemented in Python and installed by signal.signal() will be called in the main thread. It uses a signal handler implemented in C which only store the notification and will be the Python signal handler later (as early as possible). pthread_sigmask() can be used to mask some signals (or all signals) on a specific thread. ---------- nosy: +haypo, neologix _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14456> _______________________________________
Roundup Robot <devnull@psf.upfronthosting.co.za> added the comment: New changeset 52e32f3b933d by Antoine Pitrou in branch '3.2': Issue #14456: improve documentation of the signal module w.r.t. threads. http://hg.python.org/cpython/rev/52e32f3b933d New changeset 44d13f371811 by Antoine Pitrou in branch 'default': Issue #14456: improve documentation of the signal module w.r.t. threads. http://hg.python.org/cpython/rev/44d13f371811 ---------- nosy: +python-dev _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14456> _______________________________________
Antoine Pitrou <pitrou@free.fr> added the comment: Should be fixed now. ---------- nosy: +pitrou resolution: -> fixed stage: -> committed/rejected status: open -> closed _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14456> _______________________________________
Sven Marnach <sven@marnach.net> added the comment: Thanks, Antoine! It's perfectly clear now, and the newly introduces headlines are a definite improvement. ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14456> _______________________________________
Roundup Robot added the comment: New changeset 73050563053f by Martin Panter in branch '3.5': Issue #14456: Remove contradiction about blocking signals from bad merge https://hg.python.org/cpython/rev/73050563053f New changeset a8dbe6016a31 by Martin Panter in branch 'default': Issue #14456: Merge signal doc fix from 3.5 https://hg.python.org/cpython/rev/a8dbe6016a31 ---------- _______________________________________ Python tracker <report@bugs.python.org> <http://bugs.python.org/issue14456> _______________________________________
participants (4)
-
Antoine Pitrou
-
Roundup Robot
-
STINNER Victor
-
Sven Marnach