Search code examples
pythonasynchronouspython-asyncio

Why would you want to create more than one event loops in asyncio?


Why not just use the default one always? are there any usecases for creating multiple event loops?


Solution

  • I don't know the exact reason behind your question. But there are certainly use cases for using multiple loops. e.g. To increase scalability.

    We know, CPU-bound code will interfere with event-loops in a process. This will reduce throughput.

    Not if we have loops in other processes, event-loops in other processes will not be disturbed. Of course we have to think about locking mechanisms etc. If using asyncio with multiprocessing.