You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often want to be able to cancel an individual task, and have something that looks like asyncio's edge cancellation API, while keeping the advantages of structured concurrency.
In AnyIO this means creating a task group just for that task, but since this operation is async, one has to await the creation of the task group before being able to cancel the task, which is not the case in asyncio where launching and cancelling a task can be done in non-async functions:
I'm not sure this is the right way to do it, maybe I'm missing something simpler?
Do you think simulating edge cancellation is not a good idea in the first place?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I often want to be able to cancel an individual task, and have something that looks like asyncio's edge cancellation API, while keeping the advantages of structured concurrency.
In AnyIO this means creating a task group just for that task, but since this operation is async, one has to await the creation of the task group before being able to cancel the task, which is not the case in asyncio where launching and cancelling a task can be done in non-async functions:
The following
Cancellable
class is close to asyncio's API, but cancelling needs to be awaited:And the following version has a non-async cancellation:
I'm not sure this is the right way to do it, maybe I'm missing something simpler?
Do you think simulating edge cancellation is not a good idea in the first place?
Beta Was this translation helpful? Give feedback.
All reactions