Medium
Waiting for a Signal
Use an
asyncio.Event. A waiter task prints waiting, waits for the event and then prints got signal: MSG. The main coroutine starts the waiter, sleeps briefly, prints sending, stores the message and sets the event, then awaits the waiter.Input
One line (the message).
Output
Three lines.
Sample 1
Input
go
Output
waiting sending got signal: go
Sample 2
Input
hello world
Output
waiting sending got signal: hello world
Output appears here