-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix test utils on Python 3.11. #6867
Conversation
I think having a |
Could you add more detail on what's the effect of this? Meanwhile, I've let the CI run on this PR to see what's different. |
As far as I'm aware |
It seems like this is just used as a fallback under older CPython versions, but the recent ones shouldn't hit it. According to the docs at https://docs.python.org/3.11/library/asyncio-eventloop.html#asyncio.get_event_loop, it's deprecated only when there's no running loop:
And when the loop is running,
And looking at the source, it's evident that |
Also, this PR makes tests fail under Python 3.10: https://github.com/aio-libs/aiohttp/runs/7673650666?check_suite_focus=true. It causes |
I started questioning why it is even useful to have that in the test case, then saw that it is already deprecated in our docs: So, actually, I think this should be completely removed, atleast from master. Then maybe a minimum effort fix/hack for 3.x. How about just moving the call to a |
@Dreamsorcerer I guess we could drop it in 3.9 but still need in 3.8. Regarding the property — I'm not sure. Might work. |
Closing for now 😞. Hopefully someone more async-experience will pick it up 🤞 |
@@ -433,7 +433,11 @@ def setUp(self) -> None: | |||
try: | |||
self.loop = asyncio.get_running_loop() | |||
except RuntimeError: | |||
self.loop = asyncio.get_event_loop_policy().get_event_loop() | |||
try: | |||
self.loop = asyncio.get_event_loop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah this is not correct - you'll be getting a new and different loop see python/cpython#95736
@Dreamsorcerer I think this will fix it @cached_property
def loop(self):
return asyncio.get_running_loop() |
Tried it locally, didn't work: @property
def loop(self):
> return asyncio.get_running_loop()
E RuntimeError: no running event loop |
Removed loop from master completely in #7107. |
What do these changes do?
Fix test utils on Python 3.11
Are there changes in behavior for the user?
No.
Related issue number
#6757.
Checklist
CONTRIBUTORS.txt
CHANGES
folder