In aiohttp doc it reads:
- loop - an event loop used to process HTTP requests. If the loop is None, the constructor takes it from the connector, if one is specified. asyncio.get_event_loop () is used to get the default event loop by default.
Deprecated since version 2.0.
I googled but didn’t get a description of why the parameter was loop
deprecated.
I often create an object ClientSession
as follows:
loop = asyncio.get_event_loop()
session = aiohttp.ClientSession(loop=loop)
Now the parameter is loop
discarded, but just a call aiohttp.ClientSession()
without a loop will receive a warning:
Creating a client session outside the coroutine
So, why is the parameter deprecated and how to use the session correctly?
source
share