orangeqs.juice._util#
Internal utilities for Juice.
Module Contents#
Functions#
Add a note to an exception, backported for Python <3.11. |
|
Rerun async function on exception. |
|
Spawn a thread to run an async function. |
API#
- orangeqs.juice._util.add_note(exception: orangeqs.juice._util._BaseException, note: str) orangeqs.juice._util._BaseException#
Add a note to an exception, backported for Python <3.11.
Ensures the exception is rendered the same way as
BaseException.add_note()which was added in Python 3.11. See https://docs.python.org/3/library/exceptions.html#BaseException.add_note.Parameters#
exception (BaseException): The exception to attach the note to.
note (str): The note to attach.
- orangeqs.juice._util.rerun_on_exception(coro: collections.abc.Callable[orangeqs.juice._util._P, collections.abc.Awaitable[orangeqs.juice._util._T]] | None = None, *, sleeptime_s: float = 5.0) collections.abc.Callable[[collections.abc.Callable[orangeqs.juice._util._P, collections.abc.Awaitable[orangeqs.juice._util._T]]], collections.abc.Callable[orangeqs.juice._util._P, collections.abc.Awaitable[orangeqs.juice._util._T]]] | collections.abc.Callable[orangeqs.juice._util._P, collections.abc.Awaitable[orangeqs.juice._util._T]]#
Rerun async function on exception.
To prevent busy threads, sleep before rerun. The
sleeptime_sparameter specifies the time to sleep before retrying. This decorator can both be used with and without parameters:@rerun_on_exceptionor@rerun_on_exception(sleeptime_s=10).Parameters#
sleeptime_s (float, optional): Time to sleep before retrying, in seconds. Default is 5.0 seconds.
- orangeqs.juice._util.spawn_thread(future: collections.abc.Awaitable[None]) threading.Thread#
Spawn a thread to run an async function.