Why did aiohttp not consider the loop parameter in ClientSession?

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 loopdeprecated.

I often create an object ClientSessionas follows:

loop = asyncio.get_event_loop()
session = aiohttp.ClientSession(loop=loop)

Now the parameter is loopdiscarded, 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?

+4
source share

Source: https://habr.com/ru/post/1691822/


All Articles