Why Use Explicit Loop Parameter With Aiohttp?
The aiohttp library's documentation states: loop – event loop used for processing HTTP requests. If param is None, asyncio.get_event_loop() is used for getting default event loo
Solution 1:
The reason is readability and not performance.
Specifying a loop explicitly will make it easier for a developer to see where the loop instance originates from, and might make it easier to change the loop if a custom loop needs to be injected to the program.
Another popular option would be to never specify the loop parameter, and therefore assume asyncio.get_event_loop()
is always called to get a loop instance.
(It is possible to use more than one loop - for example in different threads, but this is not a common use case)
Post a Comment for "Why Use Explicit Loop Parameter With Aiohttp?"