summaryrefslogtreecommitdiff
path: root/searx/network/client.py
diff options
context:
space:
mode:
authorAlexandre Flament <alex@al-f.net>2021-09-28 19:32:59 +0200
committerGitHub <noreply@github.com>2021-09-28 19:32:59 +0200
commitc23aa5760cb42003c1372ccdef1611695504eb9e (patch)
treef99c4d26740560e9e20ac693e6a9588afc720ab4 /searx/network/client.py
parentca67f1555aa3c7dbb8dbb7ace7d4a0be9b65c717 (diff)
parent29893cf816ab7dccaa68697d5600326b82606972 (diff)
Merge pull request #343 from dalf/fix-checker-memory-issue
[fix] checker: fix memory usage
Diffstat (limited to 'searx/network/client.py')
-rw-r--r--searx/network/client.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/searx/network/client.py b/searx/network/client.py
index 925c0fdd3..a6cec352d 100644
--- a/searx/network/client.py
+++ b/searx/network/client.py
@@ -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)