asyncutils.signals¶
Functions related to asynchronous signal handling.
Functions¶
Module Contents¶
- async asyncutils.signals.wait_for_signal[T](
- processor: collections.abc.Callable[[signal.Signals], collections.abc.Awaitable[T]],
- /,
- *S: int,
- timeout: float | None = ...,
- raise_on_timeout: Literal[True],
- loop: asyncio.events.AbstractEventLoop | None = ...,
- possible_errors: tuple[asyncutils._internal.types.ExcType, Ellipsis] = ...,
- default_on_processor_failure: T,
- sigs: collections.abc.Iterable[int] = ...,
- logger: logging.Logger = ...,
- async asyncutils.signals.wait_for_signal(
- processor: collections.abc.Callable[[signal.Signals], collections.abc.Awaitable[T]],
- /,
- *S: int,
- timeout: float | None = ...,
- raise_on_timeout: Literal[True],
- loop: asyncio.events.AbstractEventLoop | None = ...,
- possible_errors: tuple[asyncutils._internal.types.ExcType, Ellipsis] = ...,
- sigs: collections.abc.Iterable[int] = ...,
- logger: logging.Logger = ...,
- async asyncutils.signals.wait_for_signal(
- processor: collections.abc.Callable[[signal.Signals], collections.abc.Awaitable[T]],
- /,
- *S: int,
- timeout: float | None = ...,
- raise_on_timeout: Literal[False] = ...,
- loop: asyncio.events.AbstractEventLoop | None = ...,
- possible_errors: tuple[asyncutils._internal.types.ExcType, Ellipsis] = ...,
- sigs: collections.abc.Iterable[int] = ...,
- logger: logging.Logger = ...,
- async asyncutils.signals.wait_for_signal(
- processor: collections.abc.Callable[[signal.Signals], collections.abc.Awaitable[T]],
- /,
- *S: int,
- timeout: float | None = ...,
- raise_on_timeout: Literal[False] = ...,
- loop: asyncio.events.AbstractEventLoop | None = ...,
- possible_errors: tuple[asyncutils._internal.types.ExcType, Ellipsis] = ...,
- default_on_processor_failure: T,
- sigs: collections.abc.Iterable[int] = ...,
- logger: logging.Logger = ...,
- async asyncutils.signals.wait_for_signal(
- processor: collections.abc.Callable[[signal.Signals], T],
- /,
- *S: int,
- timeout: float | None = ...,
- raise_on_timeout: Literal[True],
- loop: asyncio.events.AbstractEventLoop | None = ...,
- possible_errors: tuple[asyncutils._internal.types.ExcType, Ellipsis] = ...,
- default_on_processor_failure: T,
- sigs: collections.abc.Iterable[int] = ...,
- logger: logging.Logger = ...,
- async asyncutils.signals.wait_for_signal(
- processor: collections.abc.Callable[[signal.Signals], T],
- /,
- *S: int,
- timeout: float | None = ...,
- raise_on_timeout: Literal[True],
- loop: asyncio.events.AbstractEventLoop | None = ...,
- possible_errors: tuple[asyncutils._internal.types.ExcType, Ellipsis] = ...,
- sigs: collections.abc.Iterable[int] = ...,
- logger: logging.Logger = ...,
- async asyncutils.signals.wait_for_signal(
- processor: collections.abc.Callable[[signal.Signals], T],
- /,
- *S: int,
- timeout: float | None = ...,
- raise_on_timeout: Literal[False] = ...,
- loop: asyncio.events.AbstractEventLoop | None = ...,
- possible_errors: tuple[asyncutils._internal.types.ExcType, Ellipsis] = ...,
- sigs: collections.abc.Iterable[int] = ...,
- logger: logging.Logger = ...,
- async asyncutils.signals.wait_for_signal(
- processor: collections.abc.Callable[[signal.Signals], T],
- /,
- *S: int,
- timeout: float | None = ...,
- raise_on_timeout: Literal[False] = ...,
- loop: asyncio.events.AbstractEventLoop | None = ...,
- possible_errors: tuple[asyncutils._internal.types.ExcType, Ellipsis] = ...,
- default_on_processor_failure: T,
- sigs: collections.abc.Iterable[int] = ...,
- logger: logging.Logger = ...,
- Wait for an operating system level signal included in
sigs(defaultcontext.WAIT_FOR_SIGNAL_DEFAULT_SIGNALS) and the variablepositional arguments to be signaled withintimeoutand handle it.See the docs for thesignalmodule,add_signal_handler(), as well as the Wikipedia page for signals.processorshould be a function that takes the signal occurred, preferrably returning an awaitable object.Ifloopis passed, itsadd_signal_handler()andremove_signal_handler()methods will be used; a loop is created and set otherwise.Errors whose types are included inpossible_errorswill cause the loggerloggerto emit an error and the function to returndefault_on_processor_failure, orNoneif not passed.Some information related to the progress of the wait also goes to the logger.The return value of the processor is returned through this function.Note
There is limited support for signals on Windows and this function may not work as expected even with the little signals it provides. Therefore, the function emits a warning unless the console is running, in which case it would be much too annoying.