Closed u8sand closed 2 years ago
I think the solution here is to not store self._loop and all and use asyncio.get_running_loop().
What do you think?
@etianen I considered that but I wasn't sure if there are people that use the loop
argument with some specific event loop that is not the same as the one you get from asyncio.get_running_loop()
this approach (preserving the loop argument) might be less likely to break the aforementioned edge-case.
I personally never carry around a reference to the event loop in my own code (opting instead for asyncio.get_running_loop()
) so I can certainly remove this argument if you'd prefer :+1: .
Yeah, I reckon lose the reference. I can't think of a reason to support that edge case.
On Fri, 18 Feb 2022 at 14:54, Daniel Clarke @.***> wrote:
@etianen https://github.com/etianen I considered that but I wasn't sure if there are people that use the loop argument with some specific event loop that is not the same as the one you get from asyncio.get_running_loop() this approach (preserving the loop argument) might be less likely to break the aforementioned edge-case.
I personally never carry around a reference to the event loop in my own code (opting instead for asyncio.get_running_loop()) so I can certainly remove this argument if you'd prefer 👍 .
— Reply to this email directly, view it on GitHub https://github.com/etianen/aiohttp-wsgi/pull/34#issuecomment-1044649812, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABEKCEISEXX73DEUJCH7X3U3ZMRPANCNFSM5OOYWLQQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you were mentioned.Message ID: @.***>
Thanks!
Maybe you have a better idea of how to fix this but the newer version of aiohttp gives me this error:
I assume this means that somehow aiohttp is using a different event loop during request handling. The easiest way I found to fix this was just to use
asyncio.get_event_loop()
in the request handler, rather than running it at initialization. I opted to preserve the loop option and use it if explicitly specified but fall back to determining the loop at the call-site. This should preserve backwards compatibility while fixing this particular issue.