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

Add support for lazy async generators #7

Merged
merged 7 commits into from
Oct 2, 2023
Merged

Conversation

mattalbr
Copy link
Collaborator

@mattalbr mattalbr commented Sep 29, 2023

Fixes #5

gen_3 = async_yielding_iterator()

self.assertEqual(counter.value, 0)
self.assertEqual(await anext(gen_1), 1)
Copy link
Member

Choose a reason for hiding this comment

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

It looks like anext was introduced in python 3.10.

Maybe we add a manaul backport?

if sys.version_info.minor < 10:
  async def anext(iter): ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done!

@aebrahim
Copy link
Member

It looks like mypy and black are unhappy

@mattalbr mattalbr requested a review from aebrahim October 2, 2023 20:06
@mattalbr
Copy link
Collaborator Author

mattalbr commented Oct 2, 2023

FYI I updated the implementation to not block other generators while awaiting the next value, please give it a close look as it's definitely a bit more complicated!

@aebrahim aebrahim merged commit 873a571 into DelfinaCare:main Oct 2, 2023
33 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support async generators
2 participants