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 <rep...@bugs.python.org>
<http://bugs.python.org/issue26923>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to