New uasyncio feature: ThreadSafeFlag

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
User avatar
pythoncoder
Posts: 4935
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

New uasyncio feature: ThreadSafeFlag

Post by pythoncoder » Fri Feb 19, 2021 6:00 pm

I thought it was worth drawing attention to this as it's a significant enhancement.

Thanks to @jimmo uasyncio has an official thread safe way to interface with code such as interrupt service routines and code running in another thread. This is documented here. I have also updated my tutorial with some usage examples.

My irq_event primitive is now deleted. It did the same thing, using the same I/O stream technique. Just less elegantly coded ;)
Peter Hinch

User avatar
jimmo
Posts: 2244
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: New uasyncio feature: ThreadSafeFlag

Post by jimmo » Mon Feb 22, 2021 3:54 am

pythoncoder wrote:
Fri Feb 19, 2021 6:00 pm
Thanks to @jimmo uasyncio has an official thread safe way to interface with code such as interrupt service routines and code running in another thread. This is documented here. I have also updated my tutorial with some usage examples.
Thanks Peter! And great to see this in your tutorial already. Sorry this was a long time coming.

The implementation is a bit sub-optimal but we'll need some more architectural changes to improve it, but the API should stay the same. Eventually uevent (or something like it) will allow this to do some neat stuff with low power management.

Worth noting that this is only supported in nightly builds for now, and will be part of the upcoming 1.15 release.

User avatar
pythoncoder
Posts: 4935
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: New uasyncio feature: ThreadSafeFlag

Post by pythoncoder » Mon Feb 22, 2021 6:39 am

Good point. I've added a note to that effect.
Peter Hinch

Post Reply