Alex Grönholm <alex.gronh...@nextday.fi> added the comment:

I propose the following, backwards compatible solution:

Add a new keyword argument to Task.cancel(): "scope: object = None".
The behavior would be as follows: the scope is saved, and included in the 
raised CancelledError. If Task.cancel() is called again, but with scope=None 
(the default), it clears out the saved scope, if any. Any other scope will be 
ignored.

This simple change would allow for proper implementation of any context manager 
that needs to swallow or transform a CancelledError raised in the task.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue46771>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to