You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I've recently upgraded from Sanic 21.12.0 -> 23.12.0 and over this version boundary the behaviour of the exception Handler has changed (commit d255d1a, file sanic/mixins/exceptions.py) to accept Union[Exception, List[Exception]].
We're using the exception handler to catch asyncio's CancelledError which inherits from BaseException (see https://github.com/python/cpython/blob/3.9/Lib/asyncio/exceptions.py#L9). However with the Sanic upgrade Mypy is raising errors that we cannot use the exception handler to handle CancelledError, I've done some further investigation in ways of fixing this but they all seem to be limited by the argument types of fn exception in sanic/mixins/exceptions.py
Describe the solution you'd like
Allow the exception handler to handle BaseExceptions.
Additional context
No response
The text was updated successfully, but these errors were encountered:
Hmm... will have to think about this and investigate it. I do remember this being a very intentional decision, and that it was a bit of an anti-pattern that we allowed it at the time. It especially was a conflict when we overhauled the streaming pattern as it exposed some problems relating to catching timeouts (which are CancelledError), etc.
What's the use case, and how are you relying upon CancelledError?
Is there an existing issue for this?
Is your feature request related to a problem? Please describe.
I've recently upgraded from Sanic 21.12.0 -> 23.12.0 and over this version boundary the behaviour of the exception Handler has changed (commit
d255d1a
, filesanic/mixins/exceptions.py
) to acceptUnion[Exception, List[Exception]]
.We're using the exception handler to catch
asyncio
'sCancelledError
which inherits fromBaseException
(see https://github.com/python/cpython/blob/3.9/Lib/asyncio/exceptions.py#L9). However with the Sanic upgrade Mypy is raising errors that we cannot use the exception handler to handleCancelledError
, I've done some further investigation in ways of fixing this but they all seem to be limited by the argument types offn exception
insanic/mixins/exceptions.py
Describe the solution you'd like
Allow the exception handler to handle
BaseException
s.Additional context
No response
The text was updated successfully, but these errors were encountered: