mirror of
https://github.com/searxng/searxng.git
synced 2025-07-23 13:19:17 +02:00
[fix] searx.network.stream: fix memory leak
This commit is contained in:
parent
2eab89b4ca
commit
29893cf816
3 changed files with 42 additions and 17 deletions
|
@ -6,6 +6,7 @@ import asyncio
|
|||
import logging
|
||||
import threading
|
||||
|
||||
import anyio
|
||||
import httpcore
|
||||
import httpx
|
||||
from httpx_socks import AsyncProxyTransport
|
||||
|
@ -102,6 +103,9 @@ class AsyncProxyTransportFixed(AsyncProxyTransport):
|
|||
# then each new request creates a new stream and raise the same WriteError
|
||||
await close_connections_for_url(self, url)
|
||||
raise e
|
||||
except anyio.ClosedResourceError as e:
|
||||
await close_connections_for_url(self, url)
|
||||
raise httpx.CloseError from e
|
||||
except httpx.RemoteProtocolError as e:
|
||||
# in case of httpx.RemoteProtocolError: Server disconnected
|
||||
await close_connections_for_url(self, url)
|
||||
|
@ -130,6 +134,9 @@ class AsyncHTTPTransportFixed(httpx.AsyncHTTPTransport):
|
|||
# then each new request creates a new stream and raise the same WriteError
|
||||
await close_connections_for_url(self._pool, url)
|
||||
raise e
|
||||
except anyio.ClosedResourceError as e:
|
||||
await close_connections_for_url(self._pool, url)
|
||||
raise httpx.CloseError from e
|
||||
except httpx.RemoteProtocolError as e:
|
||||
# in case of httpx.RemoteProtocolError: Server disconnected
|
||||
await close_connections_for_url(self._pool, url)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue