-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Enable _uasyncio module #6041
Enable _uasyncio module #6041
Conversation
…and enable _uasyncio module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The _uasyncio
implementation of Task
does not provide__await___()
. Our internal implementation of async/await
(done by @WarriorOfWire) requires that. Otherwise code is going to fail. I had to add __await__()
in the Python version in a couple of places:
https://github.com/adafruit/Adafruit_CircuitPython_asyncio/blob/28ef812f14ef1fde1036eb83a4878bd14aa9a67d/asyncio/task.py#L152
https://github.com/adafruit/Adafruit_CircuitPython_asyncio/blob/28ef812f14ef1fde1036eb83a4878bd14aa9a67d/asyncio/core.py#L52-L53
I started to add __await__()
, but because __iter__()
is provided in a special way, I had not yet figured out how to make it work, and so did not use _uasyncio
initially.
In addition, I would like to rename _uasyncio
to _asyncio
, but that is minor.
Thank you for the comment. Now I understand why _uasyncio is missing in the modules. I'll close this PR. |
If you can see how to add |
I appreciate your work, and we can use these commits in the future, in any case. |
The
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for doing this, and testing it! I have a few changes, but I'm glad you were able to figure out an easy way to do this.
Register _asyncio module in CP manner.
The module is renamed from _uasyncio to _asyncio. The task_getiter and task_iternext are moved back to the original position. A prototype definition of task_getiter is added. I couldn't figure out MICROPY_PORT_BUILTIN_MODULES stuff well, but the module is now registered not in objmodule.c but by MP_REGISTER_MODULE. (I referred modure.c and modujson.c.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I appreciate the clarification.
You were right to use |
I suspect that tests/unix/extra_coverage.py.exp should be updated (_asyncio module may appear in repl auto-completion), though I failed to build unix/micropython-coverage so far. |
Yes, that was it. I had to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the update.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After my last set of tweaks, I tested this with a two-task blinking LEDs program on a Metro M4, and it's working. Thanks for this, @t-ikegami !
I have to shrink the matrixportal build slightly, or perhaps turn off uasyncio in that build. |
This PR fixes ticks in moduasyncio.c to work with adafruit version of asyncio, and enables _uasyncio module. With this PR, C-version of Task and TaskQueue are used in the asyncio.