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 » Wed Feb 07, 2018 9:57 am

To save others spending time to figure this out - uasyncio 2.0 requires the @pfalcon build of firmware. The version (1.7.1 of uasyncio.core) in @Damien's library works with his build. The version on PyPI is uasyncio 2.0.
Peter Hinch
Index to my micropython libraries.

jcea
Posts: 27
Joined: Fri Mar 18, 2016 5:28 pm

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

Post by jcea » Sat Feb 24, 2018 2:01 am

I am confused. Do we have a micropython fork?

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 Feb 24, 2018 5:56 am

My above statement has been overtaken by events: the official MicroPython firmware now supports uasyncio V2.0 (and earlier versions).

To answer your question there is a fork of MicroPython and the library maintained by Paul Sokolovsky (@pfalcon). Amongst other things he is developing the uasyncio library, so future changes to uasyncio may occur which initially require his firmware.

The situation was explained by @Damien here.
Peter Hinch
Index to my micropython libraries.

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

uasyncio V2.0

Post by pythoncoder » Tue Feb 27, 2018 2:40 pm

I have now tested this fairly thoroughly. It's an impressive upgrade in terms of task switching performance and there seems to be no downside. The only API change is to the initial call to get_event_loop() which needs adapting to set the queue sizes if an application runs more than 16 concurrent coroutines.
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 » Sun Dec 23, 2018 5:42 pm

The latest release of uasyncio, 2.2, requires a patch https://github.com/micropython/micropython/pull/4217 which was submitted to upstream at the beginning of October and isn't merged still. The situation with the maintenance of upstream MicroPython is discussed in more detail here: viewtopic.php?f=2&t=4358&start=30#p32315 .

Until (if) the patch is merged upstream, it's available in my fork of MicroPython, Pycopy: viewtopic.php?f=15&t=5699 , together with many other new features and optimizations. Figuring out the situation with this patch is also on critical path to other developments/optimizations in uasyncio, which I have in my tree for a year now. Among alternatives of: a) get discouraged and cease work on MicroPython and uasyncio; b) continue indecisive waiting; c) continue development, I choose the latter variant. Interested parties are welcome to join with this effort, non-interested may use the older version or develop something on their own.
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
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 » Mon Dec 24, 2018 5:45 am

@pfalcon The following statement is to save others from some reading.

The discussion around PR4217 indicates that Damien does not intend to implement it. This implies that your latest uasyncio version, and future versions, will require your MicroPython fork.
Peter Hinch
Index to my micropython libraries.

kevinkk525
Posts: 969
Joined: Sat Feb 03, 2018 7:02 pm

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

Post by kevinkk525 » Mon Dec 24, 2018 7:11 am

I read you post about your micropython-lib repo being compatible to every fork and that you want to keep it that way and that every fork has to take care about not doing changes that break compatibility. And I really like that. You even claim that in your message signatures "MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib"

Therefore I find it quite counterproductive to publish uasyncio version 2.2 to pypi (where everyone usually downloads packages from with upip) and your own repo as it is not compatible to any firmware than your own because you made changes breaking compatibility to every other fork.
I find that behaviour to be quite hypocritical. Your standard library is not so standard anymore if you break compatibility intentionally.
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode

User avatar
mattyt
Posts: 410
Joined: Mon Jan 23, 2017 6:39 am

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

Post by mattyt » Wed Dec 26, 2018 2:38 pm

@pfalcon I implore you to reconsider this decision and make the default upip install of micropython-asyncio work with mainline MicroPython. As someone who introduces a lot of beginners to MicroPython I know first-hand how much confusion this caused last time and how much consternation it's sure to create again.

Your ongoing development of uasyncio - which I, and many others are very grateful for! - could continue but perhaps by installing, say micropython-asyncio-dev. This would allow you to continue development while not breaking mainline and allow you to build your case to integrate the changes by showing what may be possible.

Would this be possible?

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

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

Post by pfalcon » Wed Dec 26, 2018 9:31 pm

make the default upip install of micropython-asyncio work with mainline MicroPython
mattyt, are you sure you knock on the right door? Did you read the post above at all? Did you read the links in it? There's a patch which needs to be merged to "make the default upip install of micropython-asyncio work with mainline MicroPython". You should implore to the maintainer of the mainline. And heck, the mainline has fallen into subpar maintenance, as discussed by the links above. I'm doing all what I can to continue development and improve the situation with the mainline too (raising questions, offering help with the maintenance, submitting patches). What are you doing to improve the situation?
Last edited by pfalcon on Wed Dec 26, 2018 11:40 pm, edited 1 time in total.
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/

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

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

Post by pfalcon » Wed Dec 26, 2018 9:43 pm

Otherwise, the concerns sounded here are exactly those which were discussed and answered in the thread linked above, viewtopic.php?f=2&t=4358&start=30#p32315 . Which shows again that there're some avid "Bob is writer, not reader"'s out there.

So, disregard "advices" like:
to save others from some reading
Stay wary of people giving them. Read the stuff, make your choices. Here's one quote from the thread linked above, as a sneak preview:
1. micropython-lib's has got a new motto: "MicroPython standard library for all ports, forks, and variants". As you know, motto can't convey all the complexity of real-world situations. The fine print is "for any variant which wants to be compatible". If Loboris doesn't want his fork to be compatible - it won't be compatible. If Adafruit brags a desire to remove standard MicroPython APIs from their fork - it won't be compatible. If George Robotics wants their variant to be not compatible - it will be such. I can't control 3rd parties.
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/

Post Reply