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 overrides signal handlers
Type: behavior Stage: patch review
Components: asyncio Versions: Python 3.11, Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Francisco Demartino, asvetlov, yselivanov
Priority: normal Keywords: patch

Created on 2021-05-22 03:09 by Francisco Demartino, last changed 2022-04-11 14:59 by admin.

Pull Requests
URL Status Linked Edit
PR 26306 open Francisco Demartino, 2021-05-22 04:05
Messages (2)
msg394174 - (view) Author: Francisco Demartino (Francisco Demartino) * Date: 2021-05-22 03:09
Hello,

It looks like when asyncio sets up a signal handler, it forgets about the previous one (if any).

Here's a patch (was about to create a PR but the default text brought me to bugs.python.org)
https://github.com/franciscod/cpython/commit/bdac885b86fbb01d0d775f40c47870e48af5fa5b

Tracked this down to the initial asyncio checkout, in commit 27b7c7ebf1039e96cac41b6330cf16b5632d9e49, a few commits before v3.4.0a4.

Not sure if this is a bug but it surprised me. I would have expected that it registered an "additional" signal handler, or at least that my previously installed signal handler would be called afterwards.

Also I'm not sure that it's a good idea to suddenly start running handlers that some current code might rely on not running, or have worked around this behaviour otherwise.

Thanks,
Francisco
msg394176 - (view) Author: Francisco Demartino (Francisco Demartino) * Date: 2021-05-22 04:02
Looks like Roger Dahl also noted this on https://bugs.python.org/issue39765:

> Second, set_signal_handler()[sic] silently and implicitly removes corresponding handlers set with signal.signal(). [...]  I think this should be documented as well.

(then has a linked PR that apparently doesn't address this second part)
History
Date User Action Args
2022-04-11 14:59:46adminsetgithub: 88378
2021-05-22 04:05:46Francisco Demartinosetkeywords: + patch
stage: patch review
pull_requests: + pull_request24904
2021-05-22 04:02:42Francisco Demartinosetmessages: + msg394176
2021-05-22 03:09:03Francisco Demartinocreate