The Wayback Machine - https://web.archive.org/web/20220508030120/https://github.com/python/cpython/pull/27955
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

bpo-44963: Implement send() and throw() methods for anext_awaitable objects #27955

Merged
merged 2 commits into from Sep 7, 2021

Conversation

Copy link
Member

@pablogsal pablogsal commented Aug 25, 2021

@pablogsal
Copy link
Author

@pablogsal pablogsal commented Aug 25, 2021

This does not cover the aclose() case.

Lib/test/test_asyncgen.py Outdated Show resolved Hide resolved
@pablogsal
Copy link
Author

@pablogsal pablogsal commented Aug 25, 2021

~Actually, I don't know if this is the way we should handle this, because this allows to call send() multiple times to the wrapped generator, which is kinda wrong, as send() here applies to the anextawaitable object 😟 ~

Or maybe we are fine, is late here (someone should check) :(

Seems we are fine:

>>> async def blech():
...     yield 1
...     yield 2
...     yield 3
...
>>> x = blech()
>>> asend_obj = anext(x)
>>> asend_obj.send(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration: 1
>>> asend_obj.send(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: cannot reuse already awaited __anext__()/asend()
>>> asend_obj = anext(x)
>>> asend_obj.send(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
StopIteration: 2
>>> asend_obj.send(None)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: cannot reuse already awaited __anext__()/asend()

1st1
1st1 approved these changes Aug 26, 2021
Copy link
Member

@1st1 1st1 left a comment

Looks good to me. Although I'm not sure this is a blocker-level thing.

Lib/test/test_asyncgen.py Show resolved Hide resolved
Copy link
Member

@1st1 1st1 left a comment

@pablogsal I'm still not sure about the semantics here. I need more time.

@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Sep 3, 2021

When you're done making the requested changes, leave the comment: I have made the requested changes; please review again.

1st1
1st1 approved these changes Sep 7, 2021
@1st1
Copy link

@1st1 1st1 commented Sep 7, 2021

@pablogsal I think this is a go for merging.

@1st1
Copy link

@1st1 1st1 commented Sep 7, 2021

@graingert Thomas, thanks for the thorough review.

@pablogsal pablogsal merged commit 533e725 into python:main Sep 7, 2021
12 checks passed
@pablogsal pablogsal deleted the bpo-44963 branch Sep 7, 2021
@miss-islington
Copy link

@miss-islington miss-islington commented Sep 7, 2021

Thanks @pablogsal for the PR 🌮🎉.. I'm working now to backport this PR to: 3.10.
🐍🍒🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Sep 7, 2021
…bjects (pythonGH-27955)

Co-authored-by: Yury Selivanov <[email protected]>
(cherry picked from commit 533e725)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
@bedevere-bot
Copy link

@bedevere-bot bedevere-bot commented Sep 7, 2021

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

@pablogsal
Copy link
Author

@pablogsal pablogsal commented Sep 7, 2021

Thanks @1st1 for all the help and thanks @graingert for the reviews and the comments!

miss-islington added a commit that referenced this issue Sep 7, 2021
…bjects (GH-27955)

Co-authored-by: Yury Selivanov <[email protected]>
(cherry picked from commit 533e725)

Co-authored-by: Pablo Galindo Salgado <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants