Skip to content

Sleeping and timing¤

tinyio.sleep(delay_in_seconds: int | float) -> Coro[None] ¤

tinyio coroutine for sleeping without blocking the event loop.

Arguments:

  • delay_in_seconds: the number of seconds to sleep for.

Returns:

A coroutine that just sleeps.


tinyio.timeout(coro: Coro[~_T], timeout_in_seconds: int | float) -> Coro[tuple[None | ~_T, bool]] ¤

tinyio coroutine for running a coroutine for at most timeout_in_seconds.

Arguments:

  • coro: another coroutine.
  • timeout_in_seconds: the maximum number of seconds to allow coro to run for.

Returns:

A coroutine that an be yielded on. This will return a pair of either (output, True) or (None, False), corresponding to whether coro completed within the timeout or not.

Warning

In the event of a timeout, then note that whilst coro will have a TimeoutError arising from the yield point it is currently waiting at, it will not also cancel any other coroutines it has scheduled or is waiting on.


tinyio.TimeoutError(BaseException) ¤

Raised by tinyio.TimeoutError inside a coroutine that has not completed within its timeout.