This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: [asyncio] Document loop.add_signal_handler
Type: enhancement Stage: resolved
Components: asyncio, Documentation Versions: Python 3.8, Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: asvetlov, docs@python, hniksic, yselivanov
Priority: normal Keywords: patch

Created on 2018-12-11 19:21 by hniksic, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 11145 merged python-dev, 2018-12-13 19:54
PR 11221 merged miss-islington, 2018-12-18 21:31
Messages (5)
msg331645 - (view) Author: Hrvoje Nikšić (hniksic) * Date: 2018-12-11 19:21
In https://stackoverflow.com/q/53704709/1600898 a StackOverflow user asked how the add_signal_handler event loop method differs from the signal.signal normally used by Python code.

The add_signal_handler documentation is quite brief - if we exclude the parts that explain the exceptions raised and how to pass keyword arguments to the callback, the meat is this sentence:

    Set callback as the handler for the signum signal.

It is only after looking at the source, and understanding asyncio, that one comes to the conclusion that the idea is to run the handler along with other event loop callbacks and coroutines, at the time when it is actually safe to invoke asyncio code.

I think this deserves to be mentioned explicitly, for example:

    Set callback as the handler for the signum signal.

    The callback will be invoked in the thread that runs the event
    loop, along with other queued callbacks and runnable coroutines.
    Unlike signal handlers registered using signal.signal(), a 
    callback registered with this function is allowed to interact
    with the event loop.
msg331708 - (view) Author: Andrew Svetlov (asvetlov) * (Python committer) Date: 2018-12-12 16:43
The proposal sounds great!
Would you prepare a pull request for docs update?
msg331767 - (view) Author: Hrvoje Nikšić (hniksic) * Date: 2018-12-13 19:55
Done, https://github.com/python/cpython/pull/11145
msg332081 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-12-18 21:31
New changeset e3666fc8effb05b555121f4ab7388df59e21f8b4 by Yury Selivanov (Hrvoje Nikšić) in branch 'master':
bpo-35465: Document _UnixSelectorEventLoop.add_signal_handler. (GH-11145)
https://github.com/python/cpython/commit/e3666fc8effb05b555121f4ab7388df59e21f8b4
msg332085 - (view) Author: Yury Selivanov (yselivanov) * (Python committer) Date: 2018-12-18 21:52
New changeset 12f3979b3807b448ca070b44bbc1597cf800f8a4 by Yury Selivanov (Miss Islington (bot)) in branch '3.7':
bpo-35465: Document _UnixSelectorEventLoop.add_signal_handler. (GH-11145) (GH-11221)
https://github.com/python/cpython/commit/12f3979b3807b448ca070b44bbc1597cf800f8a4
History
Date User Action Args
2022-04-11 14:59:09adminsetgithub: 79646
2018-12-18 21:52:40yselivanovsetmessages: + msg332085
2018-12-18 21:32:49yselivanovsetstatus: open -> closed
type: enhancement
resolution: fixed
stage: patch review -> resolved
2018-12-18 21:31:41miss-islingtonsetpull_requests: + pull_request10456
2018-12-18 21:31:37yselivanovsetmessages: + msg332081
2018-12-13 19:55:57hniksicsetmessages: + msg331767
2018-12-13 19:54:27python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request10376
2018-12-12 20:57:26asvetlovsetnosy: + yselivanov
components: + asyncio
2018-12-12 20:18:36brett.cannonsettitle: Document add_signal_handler -> [asyncio] Document loop.add_signal_handler
2018-12-12 16:43:30asvetlovsetnosy: + asvetlov
messages: + msg331708
2018-12-11 19:21:33hniksiccreate