1 from typing import AsyncIterator

2

3 from ._compat import DeprecatedAsyncContextManager

4 from ._eventloop import get_asynclib

5

6

7 def open_signal_receiver(

8 *signals: int,

9) -> DeprecatedAsyncContextManager[AsyncIterator[int]]:

10 """

11 Start receiving operating system signals.

12

13 :param signals: signals to receive (e.g. ``signal.SIGINT``)

14 :return: an asynchronous context manager for an asynchronous iterator which yields signal

15 numbers

16

17 .. warning:: Windows does not support signals natively so it is best to avoid relying on this

18 in cross-platform applications.

19

20 .. warning:: On asyncio, this permanently replaces any previous signal handler for the given

21 signals, as set via :meth:`~asyncio.loop.add_signal_handler`.

22

23 """

24 return get_asynclib().open_signal_receiver(*signals)