From ed6d891633dd5f8c80c236e0f8e5f3c6cdc9e3ed Mon Sep 17 00:00:00 2001 From: Hrvoje Niksic Date: Thu, 13 Dec 2018 20:47:53 +0100 Subject: [PATCH 1/2] bpo-35465: Document _UnixSelectorEventLoop.add_signal_handler. --- Doc/library/asyncio-eventloop.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index da2339132a403d2..4d6c89f3090ee26 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -966,6 +966,11 @@ Unix signals Set *callback* as the handler for the *signum* signal. + The callback will be invoked in the thread that runs *loop*, along with + other queued callbacks and runnable coroutines of that event loop. Unlike + signal handlers registered using :func:`signal.signal`, a callback + registered with this function is allowed to interact with the event loop. + Raise :exc:`ValueError` if the signal number is invalid or uncatchable. Raise :exc:`RuntimeError` if there is a problem setting up the handler. From a836fbe3a1f502092a6b328b3a7a60a1910631ff Mon Sep 17 00:00:00 2001 From: Hrvoje Niksic Date: Mon, 17 Dec 2018 23:06:22 +0100 Subject: [PATCH 2/2] Don't give a false impression that signal delivery will work in loops running outside the main thread. --- Doc/library/asyncio-eventloop.rst | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Doc/library/asyncio-eventloop.rst b/Doc/library/asyncio-eventloop.rst index 4d6c89f3090ee26..acf9477f723d442 100644 --- a/Doc/library/asyncio-eventloop.rst +++ b/Doc/library/asyncio-eventloop.rst @@ -966,10 +966,10 @@ Unix signals Set *callback* as the handler for the *signum* signal. - The callback will be invoked in the thread that runs *loop*, along with - other queued callbacks and runnable coroutines of that event loop. Unlike - signal handlers registered using :func:`signal.signal`, a callback - registered with this function is allowed to interact with the event loop. + The callback will be invoked by *loop*, along with other queued callbacks + and runnable coroutines of that event loop. Unlike signal handlers + registered using :func:`signal.signal`, a callback registered with this + function is allowed to interact with the event loop. Raise :exc:`ValueError` if the signal number is invalid or uncatchable. Raise :exc:`RuntimeError` if there is a problem setting up the handler. @@ -977,6 +977,9 @@ Unix signals Use :func:`functools.partial` :ref:`to pass keyword arguments ` to *callback*. + Like :func:`signal.signal`, this function must be invoked in the main + thread. + .. method:: loop.remove_signal_handler(sig) Remove the handler for the *sig* signal.