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.
uasyncio Query
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: uasyncio Query
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: uasyncio Query
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?
Do you know if your changes will be pulled into the main code?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: uasyncio Query
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.
Index to my micropython libraries.
Re: uasyncio Query
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.
I look forward to an updated uasyncio library but in the meantime, I now have the information I need to proceed. Thanks again all.
Re: uasyncio Query
How imminent is imminent? I love the module and am looking forward to the improvements.
Rich
Rich
pythoncoder wrote: ↑Thu Feb 20, 2020 5:05 pmThey 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.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: uasyncio Query
I gather it's now @Damien's priority so hopefully soon.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.