-
Notifications
You must be signed in to change notification settings - Fork 16
Lock is not preventing concurrent acquiring #29
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
Comments
@tekktrik can you take a look at this? The change appears to have been introduced by a PR about "add docstrings" which is odd. https://github.com/adafruit/Adafruit_CircuitPython_asyncio/pull/19/files#diff-6c3d301ce3f21e806072e5b6da07862be0327e8fb5245117013252c725224348R72 |
Based on a quick read, "yield" in the context of cp/mp asyncio seems to mean "don't schedule me ever, something else will manually schedule me" while "await asyncio.sleep(0)" means "reschedule me as soon as possible". However, I think that's not CPython compatible; yield in an async def is a way of writing an async generator, since python 3.6: https://stackoverflow.com/questions/37549846/how-to-use-yield-inside-async-function |
I'll take a look. The change was made to help get the linter pass, or something like that. |
If it needs to be changed back, I didn't have any reason of my own to change them as I did. |
I had to change several |
I think they have different semantics in Circuit/MicroPython. |
Closed by #30 |
asyncio.Lock() is not preventing concurrent acquiring of the lock.
Circuitpython version: Adafruit CircuitPython 7.3.3 on 2022-08-29; Adafruit Feather Bluefruit Sense with nRF52840
main.py:
Output:
When
await core.sleep(0)
is used inacquire()
, task B is able to acquire the lock even though task A has not yet released the lock. This then leads to the exception when B tries to release the lock that was already released by A.As a test I modified
asyncio/lock.py
to show that going back to usingyield
works while usingawait core.sleep(0)
does not.The text was updated successfully, but these errors were encountered: