Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/anyio/_core/_signals.py: 86%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

7 statements  

1from __future__ import annotations 

2 

3from collections.abc import AsyncIterator 

4from signal import Signals 

5from typing import ContextManager 

6 

7from ._eventloop import get_async_backend 

8 

9 

10def open_signal_receiver(*signals: Signals) -> ContextManager[AsyncIterator[Signals]]: 

11 """ 

12 Start receiving operating system signals. 

13 

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

15 :return: an asynchronous context manager for an asynchronous iterator which yields 

16 signal numbers 

17 

18 .. warning:: Windows does not support signals natively so it is best to avoid 

19 relying on this in cross-platform applications. 

20 

21 .. warning:: On asyncio, this permanently replaces any previous signal handler for 

22 the given signals, as set via :meth:`~asyncio.loop.add_signal_handler`. 

23 

24 """ 

25 return get_async_backend().open_signal_receiver(*signals)