-
Notifications
You must be signed in to change notification settings - Fork 14
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
Async repl #106
base: main
Are you sure you want to change the base?
Async repl #106
Conversation
to allow control-C to interrupt current task in async repl. Signed-off-by: Peter Chubb <[email protected]>
This allows interaction via the serial port, and on-the-fly update of the webserver's routing rules. For example one can do: ``` import asyncio from microdot.microdot import URLPattern, Response def add_action(app, url, action): p = URLPattern(url) app.url_map = [(['GET'], p, action)] + app.url_map ``` to add new rules for the main webserver app. Signed-off-by: Peter Chubb <[email protected]>
Seems like a good idea to me, given that it's completely optional. The main limitation I see is that it needs the script that you are running to allow use aiorepl, but I guess that's a limitation with MicroPython itself and not this PR. I'll play around with the PR and see how well it works. |
One question I have is, is there anyway to stop a script that's running if you're in the async REPL? |
From the async repl, it feels (almost) exactly the same as a standard repl, except that other things are running in the background. You can either set it up to share the initial context (as I did) or to have its own. If it has the initial context, then you can do:
to stop the webserver. If you start new coroutines from the repl, you can use all asyncio's methods to control them |
Signed-off-by: James Archer <[email protected]>
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.
This seems useful to me with no downside. I pushed odroidc4 support.
Okay, is there any reason why this is a draft? |
We need to start documenting what sub-set of MicroPython features we support. This being one of them. |
This is a straw-man proof of concept. It allows interacting with a REPL for examples/webserver on the qemu_virt_aarch64 platform
I can create a file 'extra.py' on the NFS server, that contains:
Then on the commandline do:
Then visiting the webserver's
/foo
prints out the counter value.It'd be trivial to extend to deleting the path and modifying existing ones.
The Asyncio repl is a bit limited compared with the standard one: the biggest limitation is one can use only single line commands.
If this is considered a good idea, I'll add it to the other webserver example platforms.