Skip to content

Relation between threads and signals unclear #58661

Closed

Description

@smarnach
mannequin
BPO 14456
Nosy @pitrou, @vstinner, @smarnach

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2012-03-31.19:15:45.741>
created_at = <Date 2012-03-30.23:12:58.024>
labels = ['docs']
title = 'Relation between threads and signals unclear'
updated_at = <Date 2016-04-11.02:47:20.948>
user = 'https://github.com/smarnach'

bugs.python.org fields:

activity = <Date 2016-04-11.02:47:20.948>
actor = 'python-dev'
assignee = 'docs@python'
closed = True
closed_date = <Date 2012-03-31.19:15:45.741>
closer = 'pitrou'
components = ['Documentation']
creation = <Date 2012-03-30.23:12:58.024>
creator = 'smarnach'
dependencies = []
files = []
hgrepos = []
issue_num = 14456
keywords = []
message_count = 7.0
messages = ['157156', '157158', '157160', '157222', '157223', '157238', '263160']
nosy_count = 6.0
nosy_names = ['pitrou', 'vstinner', 'neologix', 'docs@python', 'python-dev', 'smarnach']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue14456'
versions = ['Python 3.3']

Activity

  1. smarnach commented on Mar 30, 2012

    smarnachmannequin
    MannequinAuthor

    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.

  2. smarnach commented on Mar 30, 2012

    smarnachmannequin
    MannequinAuthor

    For reference: the functions 'pthread_kill()' etc. were intrduced in bpo-8407.

  3. vstinner commented on Mar 30, 2012

    @vstinner
    Member

    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.

  4. python-dev commented on Mar 31, 2012

    python-devmannequin
    Mannequin

    New changeset 52e32f3b933d by Antoine Pitrou in branch '3.2':
    Issue bpo-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 bpo-14456: improve documentation of the signal module w.r.t. threads.
    http://hg.python.org/cpython/rev/44d13f371811

  5. pitrou commented on Mar 31, 2012

    @pitrou
    Member

    Should be fixed now.

  6. smarnach commented on Mar 31, 2012

    smarnachmannequin
    MannequinAuthor

    Thanks, Antoine! It's perfectly clear now, and the newly introduces headlines are a definite improvement.

  7. python-dev commented on Apr 11, 2016

    python-devmannequin
    Mannequin

    New changeset 73050563053f by Martin Panter in branch '3.5':
    Issue bpo-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 bpo-14456: Merge signal doc fix from 3.5
    https://hg.python.org/cpython/rev/a8dbe6016a31

  8. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dir

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions