xnano.utils.dispatch
xnano.utils.dispatch
¶
xnano.utils.dispatch
Invoke synchronous and asynchronous hooks with supported signatures.
Functions:
-
run_awaitable–Drive an async hook result to completion on a free event loop.
-
invoke_hook–Invoke
handlerwith the right arity, awaiting async results.
run_awaitable
¶
Drive an async hook result to completion on a free event loop.
Parameters:
Returns:
-
Any–The awaitable's result.
Raises:
-
RuntimeError–If called while an asyncio event loop is already running on this thread (the sync run loop cannot nest
asyncio.run). -
TypeError–If
awaitableis not a coroutine object.
Source code in xnano/utils/dispatch.py
invoke_hook
¶
Invoke handler with the right arity, awaiting async results.
Uncaught exceptions (other than Exit / KeyboardInterrupt /
SystemExit) are logged at ERROR and re-raised so the run loop
can restore the host terminal on the way out.