SyncContext#
Understand request ownership, phases, and runtime limits. See the guide.
- class zett_agent.sync_runtime.SyncContext(runtime, source)[source]#
Adapt async with to ordinary with without changing the yielded value.
One async task owns both __aenter__ and __aexit__. This matters for task groups and cancellation scopes that must be exited by their entering task. An exception from the synchronous with body is passed to __aexit__; its truthy return suppresses the exception just as async with would.
The supplied runtime remains caller-owned. This is a resource-lifecycle adapter, not an AgentRunContext and not a synchronous proxy for the yielded resource’s methods.
Examples
Open a resource and invoke one of its asynchronous methods:
with SyncRuntime() as runtime: with runtime.context(open_connection()) as connection: runtime.call(connection.send, "Hello")
- Parameters:
runtime (SyncRuntime)
source (AbstractAsyncContextManager[_T])