I have a web application based on the Python 3.5+ asynchronous structure (apistar, sanic, etc.). The application makes various I / O calls - to the database, Redis, etc., which are also asynchronous.
Some documents recommend using an additional event loop:
import asyncio
import peewee
from peewee_async import Manager, PostgresqlDatabase
loop = asyncio.new_event_loop()
database = PostgresqlDatabase('test')
objects = Manager(database, loop=loop)
I understand that statements awaitallow the event loop to switch to context every time IO hits, so additional event loops seem completely unnecessary.
What is the advantage of using an extra event loop and when should additional loops be used?
source
share