Skip to content

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

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

Merged
merged 6 commits into from
Oct 18, 2022
Merged

Conversation

jepler
Copy link
Contributor

@jepler jepler commented Oct 14, 2022

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 adafruit/circuitpython#6954 but adafruit/circuitpython#6706 is not fixed (a different core change will fix that one)

This can be used in cases where `await SOMETHING` is required,
but the task cannot be put back on the queue like `await sleep(0)` would
do.

This passes the test and the docs build (locally)
@jepler
Copy link
Contributor Author

jepler commented Oct 15, 2022

Sadly this does not appear to fix adafruit/circuitpython#6706.

.. and use a simpler(?) way to invoke sed

I don't know why this apparently only started recently, but
circuitpython-build-tools creates build_deps/circuitpython
with a directory 'nvm.toml' inside. The existing sed command would
attempt to run on this directory.

`find pattern... -exec command... +` takes the matching items and puts
them on the command... commandline, without any concerns about
whitespace or quoting.  `for $(find...)` has several concerns about
whitespace and quoting. It also adds "-type f" to restrict the match
to only files, not directories.
@jepler jepler changed the title Make tests pass on ports/unix Fix uses of 'await sleep(0)' Oct 17, 2022
@jepler jepler marked this pull request as ready for review October 17, 2022 01:17
@jepler
Copy link
Contributor Author

jepler commented Oct 17, 2022

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

@jepler
Copy link
Contributor Author

jepler commented Oct 18, 2022

@dhalbert ready for your re-review

Copy link
Contributor

@dhalbert dhalbert left a comment

Choose a reason for hiding this comment

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

Thank you for researching and fixing this!

@dhalbert dhalbert merged commit fbdb77d into adafruit:main Oct 18, 2022
adafruit-adabot added a commit to adafruit/Adafruit_CircuitPython_Bundle that referenced this pull request Oct 19, 2022
Updating https://github.com/adafruit/Adafruit_CircuitPython_ADXL34x to 1.12.7 from 1.12.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_ADXL34x#37 from tekktrik/dev/fix-value-error

Updating https://github.com/adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306 to 1.5.10 from 1.5.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_DisplayIO_SSD1306#29 from tekktrik/dev/fix-type-annotation

Updating https://github.com/adafruit/Adafruit_CircuitPython_GPS to 3.10.6 from 3.10.5:
  > Merge pull request adafruit/Adafruit_CircuitPython_GPS#90 from tekktrik/dev/fix-example-import

Updating https://github.com/adafruit/Adafruit_CircuitPython_PM25 to 2.1.13 from 2.1.12:
  > Merge pull request adafruit/Adafruit_CircuitPython_PM25#25 from tekktrik/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_SD to 3.3.15 from 3.3.14:
  > Merge pull request adafruit/Adafruit_CircuitPython_SD#51 from calcut/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_SHTC3 to 1.1.10 from 1.1.9:
  > Merge pull request adafruit/Adafruit_CircuitPython_SHTC3#17 from tcfranks/main

Updating https://github.com/adafruit/Adafruit_CircuitPython_asyncio to 0.5.17 from 0.5.16:
  > Merge pull request adafruit/Adafruit_CircuitPython_asyncio#30 from jepler/make-tests-pass

Updating https://github.com/adafruit/Adafruit_CircuitPython_HTTPServer to 0.5.2 from 0.5.1:
  > Merge pull request adafruit/Adafruit_CircuitPython_HTTPServer#15 from FoamyGuy/smaller_file_read_buffer

Updating https://github.com/adafruit/Adafruit_CircuitPython_ImageLoad to 1.16.7 from 1.16.6:
  > Merge pull request adafruit/Adafruit_CircuitPython_ImageLoad#61 from deshipu/png

Updating https://github.com/adafruit/Adafruit_CircuitPython_Ticks to 1.0.8 from 1.0.7:
  > Merge pull request adafruit/Adafruit_CircuitPython_Ticks#8 from adafruit/try-time-ticksms
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.

Hardfault on esp32s3 when trying to release either a asyncio lock or event
2 participants