Agree with Aurelien Lambert: if you call task.cancel() there is no sense for expecting a normal result from a task. My typical code for task cancellation looks like
task.cancel() with contextlib.suppress(asyncio.CancelledError): await task If you need a partial task result you probably can build something with asyncio.Condition (or use queue) On Thu, Aug 1, 2019 at 7:20 AM <aurelien.lambert...@gmail.com> wrote: > > Which means you cancel a running task but still have to wait for it and check > if it eventually has a result. This is OK for internal use, but highly > counter intuitive for the end-user. And it makes the cancelled status even > more inconsistent, as calling cancel on a running task does not ensure it > will actually be cancelled. > > This is highly disadvised by the documentation, and I think most users ignore > a task once it has been cancelled while running. > _______________________________________________ > Python-ideas mailing list -- python-ideas@python.org > To unsubscribe send an email to python-ideas-le...@python.org > https://mail.python.org/mailman3/lists/python-ideas.python.org/ > Message archived at > https://mail.python.org/archives/list/python-ideas@python.org/message/BPKASVTS4OVV7JMJ7QY632FGMC7XVGP7/ > Code of Conduct: http://python.org/psf/codeofconduct/ -- Thanks, Andrew Svetlov _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/4VULOBLBQ4JXADBKAGOBPZNTSTJAC3IG/ Code of Conduct: http://python.org/psf/codeofconduct/