Author hniksic
Recipients docs@python, hniksic
Date 2018-12-11.19:21:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1544556093.28.0.788709270274.issue35465@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2018-12-11 19:21:33hniksicsetrecipients: + hniksic, docs@python
2018-12-11 19:21:33hniksicsetmessageid: <1544556093.28.0.788709270274.issue35465@psf.upfronthosting.co.za>
2018-12-11 19:21:33hniksiclinkissue35465 messages
2018-12-11 19:21:33hniksiccreate