uasyncio Query

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: uasyncio Query

Post by pythoncoder » Thu Feb 20, 2020 7:20 am

Normal practice is to keep the event loop running forever, either by issuing run_forever() or by issuing run_until_complete(coro()) where coro() never terminates. Within that environment you can run synchronous functions and methods as well as asynchronous coroutines.

There are rare cases in testing where you issue run_until_complete(coro()) and you have coro() terminate, returning a value. In that case CPython's asyncio allows the value to be retrieved. uasyncio V2 does not. My fast_io version fixes this and other bugs.

I've never actually used that feature except to prove whether it works. My event loops invariably run forever.
Peter Hinch
Index to my micropython libraries.

doublevee
Posts: 75
Joined: Mon Jul 02, 2018 11:09 pm

Re: uasyncio Query

Post by doublevee » Thu Feb 20, 2020 1:16 pm

Thanks Peter - that explains the exact issue I was running into. I think I will follow the advice and move everything into an infinite loop (with a run_until_complete just during testing) and call both async and normal functions as and when required. I had it in my head for some reason that you couldn't mix these - which now seems daft - but I'm learning everyday :)

Do you know if your changes will be pulled into the main code?

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

Re: uasyncio Query

Post by pythoncoder » Thu Feb 20, 2020 5:05 pm

doublevee wrote:
Thu Feb 20, 2020 1:16 pm
...
Do you know if your changes will be pulled into the main code?
They will not, because an entirely new version of uasyncio is imminent. This fixes the bugs addressed in my fork. I'm hoping it will also offer the fast I/O feature and the synchronisation primitives. I have no desire to maintain a version of uasyncio and only did so because bugfix PR's were not getting implemented. From what I've seen the new version is a big improvement.
Peter Hinch
Index to my micropython libraries.

doublevee
Posts: 75
Joined: Mon Jul 02, 2018 11:09 pm

Re: uasyncio Query

Post by doublevee » Fri Feb 21, 2020 12:06 am

Understood.

I look forward to an updated uasyncio library but in the meantime, I now have the information I need to proceed. Thanks again all.

User avatar
RWLTOK
Posts: 53
Joined: Thu Dec 14, 2017 7:24 pm

Re: uasyncio Query

Post by RWLTOK » Mon Mar 02, 2020 3:15 am

How imminent is imminent? I love the module and am looking forward to the improvements.

Rich
pythoncoder wrote:
Thu Feb 20, 2020 5:05 pm
doublevee wrote:
Thu Feb 20, 2020 1:16 pm
...
Do you know if your changes will be pulled into the main code?
They will not, because an entirely new version of uasyncio is imminent. This fixes the bugs addressed in my fork. I'm hoping it will also offer the fast I/O feature and the synchronisation primitives. I have no desire to maintain a version of uasyncio and only did so because bugfix PR's were not getting implemented. From what I've seen the new version is a big improvement.

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

Re: uasyncio Query

Post by pythoncoder » Mon Mar 02, 2020 10:11 am

I gather it's now @Damien's priority so hopefully soon.
Peter Hinch
Index to my micropython libraries.

Post Reply