adafruit / Adafruit_CircuitPython_asyncio

CIrcuitPython subset of CPython asyncio library
MIT License
27 stars 16 forks source link

Fix uses of 'await sleep(0)' #30

Closed jepler closed 2 years ago

jepler commented 2 years ago

This set of changes, together with some other changes in the core and in adafruit_circuitpython_ticks, allow all the asyncio-related core tests to pass at build time (that is, with the ports/unix build).

Probably a good place to discuss this is

Micropython can use a non-standard construct of yield in an async def to cause the async function to be suspended indefinitely, until some other task causes it to be scheduled again. await sleep(0) is equivalent, so an internal "_Never" class is introduced which can do this in a way that is syntactically valid in standard Python as well.

When using the core implementation of Task & TaskGroup, there are Problems, so this PR disables that. Doing so might also fix the following issues in the core repo, but I didn't specifically test them:

This Closes https://github.com/adafruit/circuitpython/issues/6954 but https://github.com/adafruit/circuitpython/issues/6706 is not fixed (a different core change will fix that one)

jepler commented 2 years ago

Sadly this does not appear to fix https://github.com/adafruit/circuitpython/issues/6706.

jepler commented 2 years ago

@dhalbert I think this is ready, though I could rebase it to get rid of the 'bare yield' iteration of the change.

jepler commented 2 years ago

@dhalbert ready for your re-review