Browse Source

fix: correct docstring placement

Move docstring from between function parameters to inside
the function body after the signature closing line.
pull/15922/head
Tono Developer 3 weeks ago
parent
commit
9f20a75f8d
  1. 17
      fastapi/concurrency.py

17
fastapi/concurrency.py

@ -16,16 +16,19 @@ _T = TypeVar("_T")
@asynccontextmanager
async def contextmanager_in_threadpool(
cm: AbstractContextManager[_T],
) -> AsyncGenerator[_T, None]:
"""Run a context manager in a thread pool.
Args:
cm: The context manager to run.
Allows using synchronous context managers within async
FastAPI endpoints without blocking the event loop.
Returns:
The result of the context manager.
"""
cm: AbstractContextManager[_T],
) -> AsyncGenerator[_T, None]:
Args:
cm: The synchronous context manager to execute.
Returns:
An async generator yielding the context manager result.
"""
# blocking __exit__ from running waiting on a free thread
# can create race conditions/deadlocks if the context manager itself
# has its own internal pool (e.g. a database connection pool)

Loading…
Cancel
Save