contextmanager_in_threadpool
No overview available.
def contextmanager_in_threadpool(
cm: AbstractContextManager[_T]
) - > AsyncGenerator[_T, None]
Runs a synchronous context manager's enter and exit methods within a thread pool. This is useful for integrating synchronous context managers into asynchronous codebases without blocking the event loop.
Parameters
| Name | Type | Description |
|---|---|---|
| cm | AbstractContextManager[_T] | The synchronous context manager to be run in the thread pool. Its enter and exit methods will be executed in separate threads. |
Returns
| Type | Description |
|---|---|
AsyncGenerator[_T, None] | An asynchronous generator that yields the result of the context manager's enter method. |