On Tue, Feb 19, 2019 at 12:10 PM Andrew Svetlov <andrew.svet...@gmail.com> wrote: > If the task's function swallows CancelledError exception -- it is a > programming error.
I was asking if there is a way to end such a task. Is there? The only approach I can think of without having something like set_exception() is to keep calling cancel() in a loop and waiting (but even that can fail under certain code), but I'm not sure off-hand if the API supports calling cancel() more than once. Also, I can see this happening even when there is no bug. Maybe the coroutine was properly written to cancel gracefully, but the caller doesn't want to continue waiting past a certain time. --Chris > The same as generator object technically can swallow GeneratorExit > (but such code is most likely buggy). > > On Tue, Feb 19, 2019 at 9:55 PM Chris Jerdonek <chris.jerdo...@gmail.com> > wrote: > > > > I have an asyncio question. > > > > In Python 3.7, is there a way to reliably end a task after having > > already tried calling cancel() on it and waiting for it to end? > > > > In Python 3.6, I did this with task.set_exception(), but in 3.7 that > > method was removed. > > > > --Chris > > _______________________________________________ > > Async-sig mailing list > > Async-sig@python.org > > https://mail.python.org/mailman/listinfo/async-sig > > Code of Conduct: https://www.python.org/psf/codeofconduct/ > > > > -- > Thanks, > Andrew Svetlov _______________________________________________ Async-sig mailing list Async-sig@python.org https://mail.python.org/mailman/listinfo/async-sig Code of Conduct: https://www.python.org/psf/codeofconduct/