Skip to content

asyncio.CancelledError not caught in asyncSlot error handler #126

@QQ80

Description

@QQ80

For coroutines decorated with asyncSlot, if the enclosing task is cancelled, the asyncio.CancelledError is left uncaught. This is a problem if another signal triggers the cancelling of that enclosing task, while it is awaiting for something.

I believe the error handler at line 778 of qasync/__init__.py should handle asyncio.CancelledError with something like this:

    def _error_handler(task):
        try:
            task.result()
        except Exception:
            sys.excepthook(*sys.exc_info())
        except asyncio.CancelledError:
            pass

Note that since Python 3.8, asyncio.CancelledError is a derived class of BaseException but not Exception.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions