concurrency¶
- litestar.concurrency.get_asyncio_executor() ThreadPoolExecutor | None[source]¶
Get the executor in which synchronous callables will be run within an asyncio context
- litestar.concurrency.set_asyncio_executor(executor: ThreadPoolExecutor | None) None[source]¶
Set the executor in which synchronous callables will be run within an asyncio context
- async litestar.concurrency.sync_to_thread(fn: Callable[P, T], *args: P.args, **kwargs: P.kwargs) T[source]¶
Run the synchronous callable
fnasynchronously in a worker thread.Uses
asyncio.loop.run_in_executor()to run the callable. No executor is specified by default so the current loop’s executor is used. A specific executor can be set usingset_asyncio_executor(). This does not affect the loop’s default executor.