AsyncExecutor¶
- class chancy.executors.asyncex.AsyncExecutor(worker, queue)[source]¶
Bases:
Executor
An Executor which uses asyncio to run its jobs in the main event loop.
This executor is useful for running large numbers of IO-bound jobs, as it can run many jobs concurrently without blocking the main event loop and without the high overhead of new processes or threads. However, it is not suitable for CPU-bound jobs, as it will block the main event loop and prevent other jobs & queues from running.
To use this executor, simply pass the import path to this class in the
executor
field of your queue configuration or use theExecutor
shortcut:async with Chancy("postgresql://localhost/postgres") as chancy: await chancy.declare( Queue( name="default", executor=Chancy.Executor.Async, ) )