Skip to content

Improve asyncio.loop.add_read and asyncio.loop.add_writer documentation #126137

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

Closed
jmgurney opened this issue Oct 29, 2024 · 2 comments
Closed

Improve asyncio.loop.add_read and asyncio.loop.add_writer documentation #126137

jmgurney opened this issue Oct 29, 2024 · 2 comments
Labels
docs Documentation in the Doc dir topic-asyncio

Comments

@jmgurney
Copy link

jmgurney commented Oct 29, 2024

Documentation

The documentation for add_read/add_writer (https://docs.python.org/3/library/asyncio-eventloop.html#watching-file-descriptors ) does not specify what happens if you add two different callbacks for the same fd. Do both callbacks get called? Or does only one get called? Does the first one or the last callback get called (or maybe a random one, unlikely, but could be valid per current documentation)?

Linked PRs

@jmgurney jmgurney added the docs Documentation in the Doc dir label Oct 29, 2024
@github-project-automation github-project-automation bot moved this to Todo in asyncio Oct 29, 2024
@jmgurney
Copy link
Author

jmgurney commented Oct 29, 2024

Looks like it replaces the last callback: https://floss.social/@gwidion/113392129452013893

We better check the source! [me open some .py files in cpython/Lib/asyncio] [parse some code. confirm docs to "selector.modify" at https://docs.python.org/3/library/selectors.html#selectors.BaseSelector.modify]

Yep: asyncio will just register a single reader/writer CB per FD. The previous one is cancelled when adding another.

@picnixz
Copy link
Member

picnixz commented Oct 29, 2024

Thanks! You're welcome to submit a PR for patching the docs! (but check whether there isn't more explanation in the tutorial or somewhere else; asyncio docs are a bit spread around)

@picnixz picnixz changed the title asyncio loo.add_read/add_writer documentation lacking Improve asyncio.loop.add_read and asyncio.loop.add_writer documentation Oct 30, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 9, 2025
…ter` (pythonGH-128666)

(cherry picked from commit b2adf55)

Co-authored-by: Kumar Aditya <[email protected]>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Jan 9, 2025
…ter` (pythonGH-128666)

(cherry picked from commit b2adf55)

Co-authored-by: Kumar Aditya <[email protected]>
@github-project-automation github-project-automation bot moved this from Todo to Done in asyncio Jan 9, 2025
kumaraditya303 added a commit that referenced this issue Jan 9, 2025
…iter` (GH-128666) (#128667)

gh-126137: improve docs for `loop.add_reader` and `loop.add_writer` (GH-128666)
(cherry picked from commit b2adf55)

Co-authored-by: Kumar Aditya <[email protected]>
kumaraditya303 added a commit that referenced this issue Jan 9, 2025
…iter` (GH-128666) (#128668)

gh-126137: improve docs for `loop.add_reader` and `loop.add_writer` (GH-128666)
(cherry picked from commit b2adf55)

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 topic-asyncio
Projects
Status: Done
Status: Todo
Development

No branches or pull requests

3 participants