ConnectionPool and AsyncConnectionPool remove the underlying __cause__ of the exception #991
Replies: 1 comment
|
This is still present on current main in both pool implementations. The cleanup block ends with: raise exc from Noneafter removing the request and reassigning the queue. There are two separate traceback mechanisms here. I don't see a pool-specific reason for doing that suppression. The pool is doing bookkeeping and then re-raising the same exception object; it is not translating the exception into a new abstraction at this point. A bare I would test this at the pool boundary in both sync and async variants: make the network backend fail with a distinctive underlying exception, assert the public httpcore exception remains the same type, and assert that the original diagnostic remains reachable/displayable through its exception chain. That avoids tying the regression test specifically to AnyIO's current error text. |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
I have found that both synchronous and asynchronous connection pools will catch an error in
handle_(async_)requestand re-raise it while clearing out the__cause__(withraise exc from None)Why do we clear the
__cause__in this case? This is particularly bothersome for me becauseanyiodoes not usually set messages when raisingBrokenResourceError(and other exceptions), and that results in me having only ahttpcore.ReadErrorwith an empty message, which is not very useful.In other words: I would llike to modify that line in
connection_poolso that__cause__is not replaced withNone, and so that the underlying error can appear when I collect tracebacks.All reactions