3 Dec
2017
3 Dec
'17
12:59 a.m.
Hi, I want to ask how people feel about the following. If you raise a subclass of CancelledError from within a task and then call task.result(), CancelledError is raised rather than the subclass. Here is some code to illustrate: class MyCancelledError(CancelledError): pass async def raise_my_cancel(): raise MyCancelledError() task = asyncio.ensure_future(raise_my_cancel()) try: await task except Exception: pass assert task.cancelled() # Raises CancelledError and not MyCancelledError. task.result() Does this seem right to people? Is there a justification for this? If it would help for the discussion, I could provide a use case. Thanks a lot, --Chris