user52366
user52366

Reputation: 1137

In Micropython's asyncio, how do I wait for one of two events to be set?

In a MicroPython project, on an ESP32 microcontroller, I have two events that I have created like so:

ev1 = asyncio.Event()
ev2 = asyncio.Event()

Now, in a co-routine, I would like to wait until one of the two events has been set. So basically something like this:

async func():
    # some code
    await ev1.wait() # but wait for ev1 OR ev2 to be set

How can I do this?

Upvotes: 0

Views: 29

Answers (0)

Related Questions