Can't get async iterator to work #3352
Answered
by
davidhewitt
aspcompiler
asked this question in
Questions
-
Bug DescriptionI am running 0.17.1. I have a very simple async iterator:
I got "TypeError: 'async for' received an invalid object from anext: int" when I run the following Python program:
Steps to ReproduceSee the Rust and Python programs in description BacktraceTypeError: object int can't be used in 'await' expression
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/Cellar/python@3.10/3.10.12/Frameworks/Python.framework/Versions/3.10/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "<stdin>", line 2, in task
TypeError: 'async for' received an invalid object from __anext__: int Your operating system and versionmacOS Darwin 22.5.0 Your Python version (
|
Beta Was this translation helpful? Give feedback.
Answered by
davidhewitt
Jul 29, 2023
Replies: 1 comment 6 replies
-
|
Beta Was this translation helpful? Give feedback.
6 replies
Answer selected by
aspcompiler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
__anext__
should return a python awaitable. Here you have implemented a sync iterable, consider switching to use__iter__
and__next__
.