QUERY · ISSUE
Add yield support in async function
enhancement
Checks
-
I agree to follow the MicroPython Code of Conduct to ensure a safe and respectful space for everyone.
-
I've searched for existing issues regarding this feature, and didn't find any.
Description
Just in PEP 525, it's really easy to make a async generator instead of coding a new class with aiter and anext .
Just like this:
async def test():
for i in range(5):
await something
' yield i
Code Size
I believe this is an important syntax that makes asynchronous generation as convenient as normal generators.
Implementation
- I intend to implement this feature and would submit a Pull Request if desirable.
- I hope the MicroPython maintainers or community will implement this feature.
- I would like to Sponsor development of this feature.
CANDIDATE · PULL REQUEST
extmod/uasyncio: Fix syntax of generator functions
extmod
What?
Fix the syntax of generator functions in the uasyncio package:
awaitis only valid in anasyncfunctionasyncfunctions that useyieldare actually async generators (a construct not supported by the compiler right now)
Why?
The compiler is not picky right now, but these are actually all syntax errors.