As it turns out, the apparently simple act of canceling a task would require some carefully crafted code to be made correctly.
check:
https://discuss.python.org/t/asyncio-cancel-a-cancellation-utility-as-a-coroutine-this-time-with-feeling/26304
On the first post by Jason Fried:
# https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel
task.cancel()
try:
await task
except asyncio.CancelledError:
print("...")
BUT… What if the await task took some time and something cancelled that task doing the cancelling? It is going to eat the CancelledError which goes against the contract of cancellation. So we need something a little more complicated to tell the difference between a cancellation from below and one coming from above.
It turns out a proper failproof cancel can be part of extraasync, regardless of overlap with Fried's own later project.
As it turns out, the apparently simple act of canceling a task would require some carefully crafted code to be made correctly.
check:
https://discuss.python.org/t/asyncio-cancel-a-cancellation-utility-as-a-coroutine-this-time-with-feeling/26304
On the first post by Jason Fried:
It turns out a proper failproof
cancelcan be part of extraasync, regardless of overlap with Fried's ownlaterproject.