uasyncio - asyncio-like cooperative multitasking framework for uPy

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.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by pythoncoder » Sat Dec 16, 2017 8:50 am

Excellent! Task cancellation and timeouts are great features and it's good to see them fully merged :D

(I haven't tried UDP yet)
Peter Hinch
Index to my micropython libraries.

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by pfalcon » Sat Dec 16, 2017 3:05 pm

pfalcon wrote:
Fri Dec 15, 2017 10:45 pm
UDP module is added: ...
Besides in-tree example https://github.com/pfalcon/micropython- ... ns_junk.py , there's a more involved module to interface with Xiaomi Mi Home Gateway: https://github.com/pfalcon/uaio_xiaomi_gw
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

User avatar
on4aa
Posts: 70
Joined: Sat Nov 11, 2017 8:41 pm
Location: Europe
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by on4aa » Fri Dec 22, 2017 11:44 pm

As a newbee, I am still confused about when to use the u-prefix in module names.
I got the following error when trying out the uasyncio module on a Pycom LoPy ESP32:

Code: Select all

File "/flash/lib/uasyncio/__init__.py", line 2, in <module>
ImportError: no module named 'uselect'
Neither was upip of any help:

Code: Select all

$ ./micropython -m upip install uselect
Installing to: /home/serge/.micropython/lib/
Warning: pypi.python.org SSL certificate is not validated
Error installing 'uselect': Package not found, packages may be partially installed
Serge

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by pythoncoder » Sat Dec 23, 2017 8:26 am

I think you've uncovered a build problem with certain platforms. uselect is provided by a C module (extmod/moduslect.c) so this needs to be specified in the makefile.

Your best recourse is to raise issues on GitHub with the platform maintainers, which I see you've done against the ESP32. I'm unfamiliar with the PyCom boards and whether their firmware will automatically pick up fixes applied to the official ESP32 port.
Peter Hinch
Index to my micropython libraries.

User avatar
on4aa
Posts: 70
Joined: Sat Nov 11, 2017 8:41 pm
Location: Europe
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by on4aa » Sat Dec 23, 2017 4:40 pm

Thanks, Peter. Actually, I got one step further by replacing uselect by select in the source code of __init__.py.

However, then I get stuck on import utimeq in core.py for which I find no alternative with Pycom.
Serge

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by pythoncoder » Sat Dec 23, 2017 6:47 pm

The utimeq module is fundamental to uasyncio. If you did a pip install it should be there. Alternatively it may be found in micropython-lib. It is a Python file.
Peter Hinch
Index to my micropython libraries.

User avatar
on4aa
Posts: 70
Joined: Sat Nov 11, 2017 8:41 pm
Location: Europe
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by on4aa » Sat Dec 23, 2017 9:13 pm

It seems your uasyncio module is in high demand on Pycom, Peter!
Somebody else is also trying to get it running on a WiPy 2.
Serge

User avatar
on4aa
Posts: 70
Joined: Sat Nov 11, 2017 8:41 pm
Location: Europe
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by on4aa » Sat Dec 23, 2017 9:52 pm

Dear Peter,
This is exactly the issue. The module utimeq is not a python file in micropython-lib, but rather c source compiled into the standard library.
Unfortunately, this is not the case with default Pycom MicroPython.
Serge

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by pythoncoder » Sun Dec 24, 2017 8:23 am

on4aa wrote:
Sat Dec 23, 2017 9:13 pm
It seems your uasyncio module is in high demand on Pycom, Peter!
I must correct that - uasyncio is the work of the MicroPython maintainers, notably Paul. I am merely an enthusiastic user.

You are of course right about utimeq - I posted that in a hurry before turning off my PC which is usually a mistake.

Opinions on PyCom support vary - it will be an interesting test of it. I'd have thought that an up-to-date uasyncio was near-vital on a wireless enabled product.
Peter Hinch
Index to my micropython libraries.

User avatar
on4aa
Posts: 70
Joined: Sat Nov 11, 2017 8:41 pm
Location: Europe
Contact:

Re: uasyncio - asyncio-like cooperative multitasking framework for uPy

Post by on4aa » Tue Dec 26, 2017 10:32 pm

pythoncoder wrote:
Sun Dec 24, 2017 8:23 am
Opinions on PyCom support vary [...] I'd have thought that an up-to-date uasyncio was near-vital on a wireless enabled product.
I fully agree. It also comes a bit as a surprise and disappointment that they are not more in step with Pyboard MicroPython.

Do you recon I could manage to achieve acceptable performance using just Pycom's _thread and machine.Timer?
I need to simultaneously manage a user interface with screen and buttons, as well as a periodic measuring and transmission process.

What would be the most important uasyncio feature I will miss out on?

(The answers to these questions form perhaps additional material for your excellent uasyncio tutorial.
Serge

Post Reply