Page 1 of 1

A threading.Event() like concept in MicroPython?

Posted: Tue Jul 26, 2022 1:15 am
by Jibun no kage
A Python threading.Event() like concept in MicroPython? I happen to be using a Raspberry Pi Pico, so thinking maybe custom class that is interrupt based? Not sure, but figure someone has implemented something similar?

Re: A threading.Event() like concept in MicroPython?

Posted: Tue Jul 26, 2022 9:07 am
by pythoncoder
I suggest you explain more fully what you're trying to achieve. The Pi Pico has two cores and it's possible to use both via the _thread library. Otherwise concurrency is handled by uasyncio see also this doc.

Re: A threading.Event() like concept in MicroPython?

Posted: Sat Jul 30, 2022 4:26 pm
by Jibun no kage
Actually I asked this when I first tried to port some straight python to Micro. I soon realized, it would be easier, faster, to just rewrite the solution (a MQTT based project) from a Micro mindset from the ground up. This lead me to asyncio, and then to using mqtt_as, because I was having some issues using mqtt simple then robust in turn. Even considered creating a simple EventClass, but that proved unnecessarily. For one-off timeout need, the native machine.Timer works, or as you would comment, using Polling (i.e. nod to NTP query for example). Of course for periodic timers asyncio create task works, and since I am already using mqtt_as, easy to do.