Skip to content

GH-82604: fix docs about configuring event loop #97755

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

Merged
merged 2 commits into from
Oct 4, 2022

Conversation

kumaraditya303
Copy link
Contributor

@kumaraditya303 kumaraditya303 commented Oct 3, 2022

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this approach. Let's instead update the example to use set_event_loop_policy() instead. That is honored by asyncio.run() so we won't need the note.

(Didn't the OP mention this is also a problem with the proactor docs?)

@kumaraditya303
Copy link
Contributor Author

Let's instead update the example to use set_event_loop_policy() instead. That is honored by asyncio.run() so we won't need the note.

Do you mean to subclass the policy and then override the selector?

(Didn't the OP mention this is also a problem with the proactor docs?)

I didn't find any mention in proactor docs.

@gvanrossum
Copy link
Member

Do you mean to subclass the policy and then override the selector?

Yeah, it looks like you can do something like this (untested)

class MyPolicy(asyncio.DefaultEventLoopPolicy):
    def new_event_loop(self):
        selector = <what the example had>
        return asyncio.SelectorEventLoop(selector)

asyncio.set_event_loop_policy(MyPolicy())

@gvanrossum
Copy link
Member

I didn't find any mention in proactor docs.

Okay no worries about that then.

Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do it!

@gvanrossum gvanrossum merged commit 53503ff into python:main Oct 4, 2022
@miss-islington
Copy link
Contributor

Thanks @kumaraditya303 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-97832 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Oct 4, 2022
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 4, 2022
@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Oct 4, 2022
@bedevere-bot
Copy link

GH-97833 is a backport of this pull request to the 3.10 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 4, 2022
@kumaraditya303 kumaraditya303 deleted the async-docs branch October 4, 2022 16:48
miss-islington added a commit that referenced this pull request Oct 4, 2022
(cherry picked from commit 53503ff)

Co-authored-by: Kumar Aditya <[email protected]>
miss-islington added a commit that referenced this pull request Oct 4, 2022
(cherry picked from commit 53503ff)

Co-authored-by: Kumar Aditya <[email protected]>
pablogsal pushed a commit that referenced this pull request Oct 22, 2022
(cherry picked from commit 53503ff)

Co-authored-by: Kumar Aditya <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news topic-asyncio
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event loop implementation docs advertise set_event_loop which doesn't work with asyncio.run
4 participants