KeyError exception raised when Trio task is cancelled
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 3.7k
- Forks
- 206
- PR merge metrics
- No merged PRs in 30d
Description
When using quart-trio, with the versions specified below, if a Trio task is cancelled, a KeyError("Custom exceptions must be subclasses of Exception.") exception is raised. This is because "trio.Cancelled" class is defined as "class Cancelled(BaseException, metaclass=NoPublicConstructor)", i.e. it does not inherit from Exception, but rather from BaseException (from which Exception inherits).
This causes some strange behavior, which may or may not be related tome hang issues I'm experiencing. I assume this is a bug which is why I am submitting this.
This might also require changes in quart-trio to accommodate BaseException everywhere instead of Exception though I am not certain.
Environment:
- Python version: 3.11.4
- Quart version: 0.18.4
- Quart-trio version: 0.10.0
- Trio version: 0.22.0
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the cancellation with Python 3.11.4, Quart 0.18.4, quart-trio 0.10.0, and Trio 0.22.0, then trace where the cancelled task is handled. Review the interaction between quart-trio and Quart exception handling; done means cancellation no longer raises KeyError("Custom exceptions must be subclasses of Exception.").
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100