A threading.Event() like concept in MicroPython?
-
- Posts: 144
- Joined: Mon Jul 25, 2022 9:45 pm
A threading.Event() like concept in MicroPython?
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?
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: A threading.Event() like concept in MicroPython?
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.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 144
- Joined: Mon Jul 25, 2022 9:45 pm
Re: A threading.Event() like concept in MicroPython?
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.