Avoid handle BaseException
just for cover async task cancellation.
#805
-
Actually, I noticed by https://github.com/encode/httpcore/pull/802/files#r1326095576. In #802, he tries to handle all of Actually, not only here, also where #726 implemented: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 12 replies
-
Can you describe and demonstrate a behaviour that you want to see changed? |
Beta Was this translation helpful? Give feedback.
-
I think the most graceful way to do what you're attempting here would be adding the following in EXCEPTION_OR_CANCELLED = (Exception,)
try:
import trio # trio support is available to httpcore
EXCEPTION_OR_CANCELLED += (trio.CancelledError,)
except ImportError:
pass
try:
import anyio # asyncio support is available to httpcore
import asyncio
EXCEPTION_OR_CANCELLED += (asyncio.Cancelled,)
except ImportError:
pass And then import and use EXCEPTION_OR_CANCELLED in the existing try:
...
except EXCEPTION_OR_CANCELLED as exc:
... The would seem to me to be the simplest approach that would work fine for both the |
Beta Was this translation helpful? Give feedback.
I think the most graceful way to do what you're attempting here would be adding the following in
_syncronization.py
...And then import and use EXCEPTION_OR_CANCELLED in the existing
BaseException
cases...The would seem to me to be the simplest approach that would work fine for both the
_…