In the aiohttp's doc reads:
- loop – event loop used for processing HTTP requests. If loop is None the constructor borrows it from connector if specified. asyncio.get_event_loop() is used for getting default event loop otherwise.
Deprecated since version 2.0.
I googled but didn't get any description about why the loop
parameter is deprecated.
I often create ClientSession
object like this:
loop = asyncio.get_event_loop()
session = aiohttp.ClientSession(loop=loop)
Now the loop
parameter is depracted, but just call aiohttp.ClientSession()
without the loop will get a warning:
Creating a client session outside of coroutine
So why the parameter is deprecated and how to use the session correctly?