uasyncio-friendly REPL?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
jdts
Posts: 36
Joined: Mon Dec 23, 2019 2:55 pm

uasyncio-friendly REPL?

Post by jdts » Tue Oct 12, 2021 1:23 pm

I've found asyncio to be very powerful for developing network-attached uPython apps with lots of interacting delays and send/receive's. But one limitation for development is that uasyncio.run (required for any task to run) blocks the REPL.

I wonder if it would be possible to enable the uasyncio event loop to give time to the REPL, perhaps via some special argument to run? It seems to be clearly technically possible, since tools which steal CPU time at a lower level, e.g. ones attached to network sockets like telnet and FTP, can certainly still read and exec statements while an asyncio program is looping. For example the new SITE command capability of uftpd can easily be used to exec uPython statements while uasyncio is running. I've been using that as a workaround, but you lose all the features of the real REPL (paste mode!).

Note that this is different than an "asyncio-enabled REPL", e.g. what you get since v3.8 with "python -m asyncio". In that case you can directly await and schedule tasks in the REPL itself, and an event loop is implicitly run for you. That would also be convenient, but sounds perhaps more involved for uPython than simply "sharing cycles with the REPL".

Post Reply