Hard
Cancel a Task
Start a task that loops forever printing nothing and sleeping 0.01 s. After awaiting
asyncio.sleep(0.03), cancel it, await it, catch asyncio.CancelledError and print cancelled, then print whether task.cancelled() is True. The input is ignored except as a label printed first.Input
One word.
Output
Three lines.
Sample 1
Input
start
Output
start cancelled True
Sample 2
Input
x
Output
x cancelled True
Output appears here