Grokking Concurrency in Python
0% completed
How Cancellation Works
What happens inside an asyncio task when another part of the program calls task.cancel()? Many engineers expect the task to stop at once, as a process stops when it receives a kill signal. It does not, and nothing outside the task can stop it directly.
Instead, the task receives an exception at the line where it is waiting, runs its own cleanup code, and then ends. A task can also catch that exception and keep running, which is the source of most cancellation bugs in asyncio code.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%