flowno.utilities.coroutine_wrapper
Coroutine wrapper for Flowno’s asynchronous execution logging.
This module provides a wrapper for Python coroutines that adds detailed logging for debugging purposes. The wrapper logs coroutine execution events including creation, resumption, yielding, and completion.
For examples and more detailed information, see the flowno.utilities.logging
module
and its log_async decorator which uses this wrapper.
- class flowno.utilities.coroutine_wrapper.CoroutineWrapper(coro: Coroutine[Yield, object, T], func_name: str, arg_str: str)[source]
Wrapper for coroutines to add detailed logging.
This wrapper intercepts coroutine operations and logs execution events, making it easier to debug complex asynchronous workflows in Flowno. Used internally by the log_async decorator.
- Logs when the coroutine is:
Created
Started/Resumed (via send or throw)
Yielding commands to the event loop
Returning awaited values
Ensures that exceptions are propagated correctly.
- send(value: object) Yield [source]
Send a value into the coroutine. Return next yielded value or raise StopIteration.
- throw(typ: type[BaseException], val: BaseException | object = None, tb: TracebackType | None = None, /) Yield [source]
- throw(typ: BaseException, val: None = None, tb: TracebackType | None = None, /) Yield
Raise an exception in the coroutine. Return next yielded value or raise StopIteration.