support icon indicating copy to clipboard operation
support copied to clipboard

[Feature] asyncio.Event (or other way to let one coroutine block on another)

Open abliss opened this issue 2 months ago • 4 comments

Is your feature request related to a problem? Please describe. When using multitasking, I would like to have one coroutine block to await something happening in another coroutine. Currently I think I have to setup a sleeping-wait loop for this, which is unsatisfactory because lower sleep amounts waste resources and higher sleep amounts make the latency worse. I see that uselect offers polling but apparently only for FileIO streams, so it's not clear if I can use this to do what I want.

Describe the solution you'd like I'd like to be able to instantiate an asyncio.Event object as described in https://docs.micropython.org/en/latest/library/asyncio.html#class-event so that one coroutine can event.clear(); await event.wait() and a second coroutine can run event.set() when it's ready to unblock the first one. Describe alternatives you've considered I tried running the above code on the spike prime hub but it said no module named 'asyncio'.

abliss avatar Nov 13 '25 19:11 abliss