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
{{ message }}
Repository navigation
Exceptions not handled properly in the proxy's AsyncTunnelHTTPConnection leading to the leaks and pool starvation #1023
FWIW to move forward on this issue, I opted for a monkey patch in my code base. Hopefully only temporary. The monkey patch looks more or less like this:
_original_handle_async_request = AsyncTunnelHTTPConnection.handle_async_request
@functools.wraps(_original_handle_async_request)
async def _patched_handle_async_request(self, request):
"""Wrapper around ``handle_async_request`` that cleans up the inner
connection when a tunnel setup error (e.g. TLS handshake failure)
leaves it as a zombie.
"""
try:
return await _original_handle_async_request(self, request)
except BaseException:
if not self._connected and not self._connection.is_closed():
with AsyncShieldCancellation():
await self._connection.aclose()
raise
def apply():
if (
AsyncTunnelHTTPConnection.handle_async_request
is not _patched_handle_async_request
):
AsyncTunnelHTTPConnection.handle_async_request = (
_patched_handle_async_request
)
Activity
rail-chamidullin-myriad commentedon Dec 12, 2025
@janosik47 I am dealing exactly with the same issue and I got to the same conclusion as you. Any update on this? Is there some PR with the fix?
janwijbrand commentedon Apr 9, 2026
FWIW to move forward on this issue, I opted for a monkey patch in my code base. Hopefully only temporary. The monkey patch looks more or less like this: