Sorry but with this code I'm starting to doubt your experience (at least in regards of python). You should be able to find the mistakes yourself but I'll give you a hint anyways as you might have misunderstood some underlying concepts (which are the same as in python..):
The queue will always be empty because you don't add anything to it.
Uasyncio and mqtt_as don't access your queue in any way.
If you just want to print the length of the Uasyncio queue use this:
loop=asyncio.get_event_loop()
print(len(loop.waitq))
Resilient aysnchronous MQTT optimim use
-
- Posts: 969
- Joined: Sat Feb 03, 2018 7:02 pm
Re: Resilient aysnchronous MQTT optimim use
Kevin Köck
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
Micropython Smarthome Firmware (with Home-Assistant integration): https://github.com/kevinkk525/pysmartnode
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
-
- Posts: 40
- Joined: Fri Jul 26, 2019 9:40 pm
Re: Resilient aysnchronous MQTT optimim use
Quite right. Asyncio is new to me. Not at all familiar with it and learning
Thanks
Thanks
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Resilient aysnchronous MQTT optimim use
In the general case it's not as simple as that because there are two queues: there is also .runq.kevinkk525 wrote: ↑Tue Jul 30, 2019 5:00 pmIf you just want to print the length of the Uasyncio queue use this:
loop=asyncio.get_event_loop()
print(len(loop.waitq))
.waitq holds tasks which are suspended pending a time delay whereas .runq holds tasks which are ready to run. If a task yields with
Code: Select all
await asyncio.sleep(0)
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 40
- Joined: Fri Jul 26, 2019 9:40 pm
Re: Resilient aysnchronous MQTT optimim use
Thank you Peter, that's kind.
I really don't wish to use this thread as a vehicle for me to learn (u)asyncio and bother you two kind and generous people. Just point me to a module/object/function spec.
This really is a diverting branch to facilitating a comms method for what I'm doing elsewhere, and grateful that I can use and monitor this resilient function with some degree of competence. It's an enabler. Once I'm confident that I'm employing the features with reasonable competence, then I'll be off to the main task.
Robin
I really don't wish to use this thread as a vehicle for me to learn (u)asyncio and bother you two kind and generous people. Just point me to a module/object/function spec.
This really is a diverting branch to facilitating a comms method for what I'm doing elsewhere, and grateful that I can use and monitor this resilient function with some degree of competence. It's an enabler. Once I'm confident that I'm employing the features with reasonable competence, then I'll be off to the main task.
Robin