-
Notifications
You must be signed in to change notification settings - Fork 10.6k
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
Get eventloop from event_loop_policy to avoid deprecation warning. #5689
Get eventloop from event_loop_policy to avoid deprecation warning. #5689
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5689 +/- ##
==========================================
+ Coverage 88.66% 88.83% +0.16%
==========================================
Files 162 162
Lines 10995 11003 +8
Branches 1799 1800 +1
==========================================
+ Hits 9749 9774 +25
+ Misses 966 948 -18
- Partials 280 281 +1
|
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.
Could you add a test for this change?
I think windows tests should cover these changes. But I couldn't see windows coverage reports being uploaded. |
I meant a test to verify that the warning is no longer triggered, for which I imagine there is no existing test. Good point about coverage, though. We need to look into that. |
|
Oh right, you said it's a partial fix. |
@wRAR Can I move |
What do you mean by |
Yes. def get_asycio_event_loop_policy():
policy = asyncio.get_event_loop_policy()
if (
sys.version_info >= (3, 8)
and sys.platform == "win32"
and not isinstance(policy, asyncio.WindowsSelectorEventLoopPolicy)
):
policy = asyncio.WindowsSelectorEventLoopPolicy()
asyncio.set_event_loop_policy(policy)
return policy |
I think it's fine to put it into utils.reactor? utils.defer already imports utils.reactor. |
c3fb766
to
6bd6161
Compare
Should the remaining warning be fixed by passing |
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.
Perfect!
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.
The code looks good to me.
Can someone manually verify that the new test fails if the other changes are reverted? That’s the only thing I wanted to check manually when I found the time.
@Gallaecio I've changed the test in the master branch and ran it, I got |
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.
@Godson-Gnanaraj Thanks!
Fixes #5685
Use
policy.get_event_loop()
instead ofasyncio.get_event_loop()
.If there is no event loop running, policy will create new_event_loop.