[issue26923] asyncio.gather drops cancellation

Johannes Ebke report at bugs.python.org
Mon Jun 20 07:27:20 EDT 2016


Johannes Ebke added the comment:

Right, that's neater. Attached is a patch with your version and a test. I checked that it fails with the old version of cancel() and passes with the new one.

Concerning possible other bugs, I've had a look in the standard library, but could not find another instance where Future.cancel() is overwritten and has special handling. I also had a look at the try/except Exception blocks in lib/asyncio, but possible Cancellations are handled correctly there.

I believe the main source of bugs in this context will probably be other asyncio-based libraries. Either by inadvertently catching CancellationErrors in a try/except Exception block and treating them like other errors, or by not protecting resources with try/finally across yield points which might throw a CancellationError.

Not all libraries use cancel() internally, so the authors might not be aware that they have to write "cancellation-safe" code.

----------
Added file: http://bugs.python.org/file43485/fix_and_test_26923.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26923>
_______________________________________


More information about the Python-bugs-list mailing list