diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-04-12 17:34:21 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-12 17:34:21 +0200 |
| commit | 01cefffbf6efa8a027e0e7d720970fffadb6337a (patch) | |
| tree | a4c37f7b73897c7635ee5fab01c1e8e967e23d8a /searx/search/checker/impl.py | |
| parent | 6c0114567e7ba1b3f4a54327eddf658b7474ca58 (diff) | |
| parent | d14994dc73ba5c95382812581dac146d9eceaafa (diff) | |
Merge pull request #1 from metasearch-lab/httpx_networks
Httpx networks
Diffstat (limited to 'searx/search/checker/impl.py')
| -rw-r--r-- | searx/search/checker/impl.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/searx/search/checker/impl.py b/searx/search/checker/impl.py index ad45440ea..e54b3f68d 100644 --- a/searx/search/checker/impl.py +++ b/searx/search/checker/impl.py @@ -11,9 +11,9 @@ from urllib.parse import urlparse import re from langdetect import detect_langs from langdetect.lang_detect_exception import LangDetectException -import requests.exceptions +import httpx -from searx import poolrequests, logger +from searx import network, logger from searx.results import ResultContainer from searx.search.models import SearchQuery, EngineRef from searx.search.processors import EngineProcessor @@ -75,8 +75,8 @@ def _is_url_image(image_url): while retry > 0: a = time() try: - poolrequests.set_timeout_for_thread(10.0, time()) - r = poolrequests.get(image_url, timeout=10.0, allow_redirects=True, headers={ + network.set_timeout_for_thread(10.0, time()) + r = network.get(image_url, timeout=10.0, allow_redirects=True, headers={ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0', 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8', 'Accept-Language': 'en-US;q=0.5,en;q=0.3', @@ -90,10 +90,10 @@ def _is_url_image(image_url): if r.headers["content-type"].startswith('image/'): return True return False - except requests.exceptions.Timeout: + except httpx.TimeoutException: logger.error('Timeout for %s: %i', image_url, int(time() - a)) retry -= 1 - except requests.exceptions.RequestException: + except httpx.HTTPError: logger.exception('Exception for %s', image_url) return False |