Hello there,
My project needs multithreading and some kind of locks.
As far as I know, _thread has not supported any kind of locks.
So do you know a workaround for that?
async could be one, but it is not supported on pycom boards. Is there a way to use it?
Which path should I choose?
thread vs uasyncio
-
- Posts: 1
- Joined: Wed Jan 26, 2022 3:32 pm
- Contact:
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: thread vs uasyncio
The _thread module is experimental and poorly documented. However you should be able to issue
That said, uasyncio is the best solution in most cases: it is very much more efficient on lightweight targets. Developing under cooperative schedulers is much easier than with preemptive ones. I can point you at docs to support this assertion if you wish.
If Pycom don't support asynchronous programming, their firmware is ill suited for serious applications (in my opinion).
Code: Select all
lock = _thread.allocate_lock()
lock.acquire()
# ...
lock.release()
If Pycom don't support asynchronous programming, their firmware is ill suited for serious applications (in my opinion).
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.