[Async-sig] killing tasks that won't cancel

Chris Jerdonek chris.jerdonek at gmail.com
Tue Feb 19 18:53:01 EST 2019


On Tue, Feb 19, 2019 at 12:33 PM Yury Selivanov <yselivanov at gmail.com>
wrote:

> Unfortunately asyncio isn't super flexible around "cancellation with a
> timeout" kind of scenarios. The current assumption is that once the
> cancellation is requested, the Task will start cancelling and will do so in
> a timely manner.  Imposing a second layer of timeouts on the cancellation
> process itself isn't natively supported.  But to properly address this we
> don't need a very broadly defined Task.set_exception(); we need to rethink
> the cancellation in asyncio (perhaps draw some inspiration from Trio and
> other frameworks).
>

What options have you already considered for asyncio's API? A couple naive
things that occur to me are adding task.kill() with higher priority than
task.cancel() (or equivalently task.graceful_cancel() with lower priority).
Was task.cancel() meant more to have the meaning of "kill" or "graceful
cancel"? In addition, the graceful version of the two (whichever that may
be) could accept a timeout argument -- after which the exception of higher
priority is raised. I realize this is a more simplistic model compared to
the options trio is considering, but asyncio has already gone down the path
of the simpler approach.

--Chris



>
> Yury
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/async-sig/attachments/20190219/16a8ff8c/attachment-0001.html>


More information about the Async-sig mailing list