Selora
02/10/2025, 3:14 PMMarvin
02/10/2025, 3:14 PM.submit()
method for tasks, they are indeed pushed to a ThreadPoolTaskRunner
by default. This means that tasks are executed in a thread pool, which is not inherently asynchronous in the sense of using an asyncio
event loop. Instead, it leverages threads to achieve concurrency.
If you're working with asynchronous tasks and want to manage them using an asyncio
event loop, you might consider using AsyncTaskRunner
instead. This would allow you to leverage Python's asyncio
capabilities more directly.
Here's a brief overview of what you might consider:
- ThreadPoolTaskRunner: Good for CPU-bound tasks or when using libraries that are not asynchronous.
- AsyncTaskRunner: Suitable for I/O-bound tasks and when you want to take full advantage of Python's asyncio
features.
For more details, you can refer to the Prefect task runners documentation and the Prefect tasks documentation.
If you have more specific needs or details about your tasks, feel free to share!Selora
02/10/2025, 3:16 PM