When should I use threads or processes with asyncio instead of trying to make everything awaitable?

2 days ago 3
ARTICLE AD BOX

I am building a Python service using asyncio and I am trying to keep my code fully async. However, my real workload includes CPU-heavy tasks like parsing large files and data transformations, plus some third-party libraries that are blocking and do not provide async APIs.

I know I can use loop.run_in_executor or asyncio.to_thread for blocking operations, and I could also use multiprocessing. But in practice, how do experienced developers decide which parts should stay fully async, which should use a thread pool, and when it is better to isolate work into a separate process or service?

I am looking for practical decision rules and patterns that work in production, not just toy examples. What are the tradeoffs?

Read Entire Article