Skip to content
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

Cannot pause asyncio transport immediately #103607

Closed
LasseBlaauwbroek opened this issue Apr 18, 2023 · 2 comments
Closed

Cannot pause asyncio transport immediately #103607

LasseBlaauwbroek opened this issue Apr 18, 2023 · 2 comments
Labels
stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error

Comments

@LasseBlaauwbroek
Copy link

LasseBlaauwbroek commented Apr 18, 2023

Bug report

When creating a asyncio transport/protocol pair, one might want to call transport.pause_reading() immediately when protocol.connection_made() is called. This is currently not possible. The call to pause_reading() is ignored, and reading commences nonetheless.

This is problematic, because there is no other place where the transport can be immediately paused, especially when the protocol is created through loop.create_server.

As a remedy, I would suggest guarding

self._loop.call_soon(self._add_reader,
self._sock_fd, self._read_ready)

with if not self._paused:. There might be other places where this is needed, for other event loops.

Linked PRs

@LasseBlaauwbroek LasseBlaauwbroek added the type-bug An unexpected behavior, bug, or error label Apr 18, 2023
@arhadthedev arhadthedev added topic-asyncio stdlib Python modules in the Lib dir labels Apr 18, 2023
@gvanrossum
Copy link
Member

@LasseBlaauwbroek This makes sense, could you make a PR (with tests, please)?

@arhadthedev
Copy link
Member

gh-17425 is a PR from gh-76002 closed as a duplicate of this issue.

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Apr 27, 2023
…tion_made` in `asyncio`. (pythonGH-17425)

(cherry picked from commit 78942ec)

Co-authored-by: Itayazolay <itayazolay@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
kumaraditya303 added a commit that referenced this issue Apr 27, 2023
…ade` in `asyncio`. (#17425)

Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
kumaraditya303 added a commit that referenced this issue Apr 27, 2023
…ction_made` in `asyncio`. (GH-17425) (#103918)

gh-103607: Fix `pause_reading` to work when called from `connection_made` in `asyncio`. (GH-17425)
(cherry picked from commit 78942ec)

Co-authored-by: Itayazolay <itayazolay@gmail.com>
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir topic-asyncio type-bug An unexpected behavior, bug, or error
Projects
Status: Done
Development

No branches or pull requests

4 participants