1
0
mirror of https://github.com/searxng/searxng.git synced 2024-11-17 18:00:12 +01:00

[mod] remove deprecate code

remove code to support Python 3.5 and Python 3.6
This commit is contained in:
Alexandre Flament 2022-01-29 08:54:12 +01:00
parent 8f100d7046
commit f3f61df6a0
2 changed files with 2 additions and 25 deletions

View File

@ -38,7 +38,7 @@ def ahmia_blacklist_loader():
This function is used by :py:mod:`searx.plugins.ahmia_filter`. This function is used by :py:mod:`searx.plugins.ahmia_filter`.
""" """
with open(str(data_dir / 'ahmia_blacklist.txt'), encoding='utf-8') as f: with open(data_dir / 'ahmia_blacklist.txt', encoding='utf-8') as f:
return f.read().split() return f.read().split()

View File

@ -5,41 +5,18 @@
import asyncio import asyncio
import threading import threading
import concurrent.futures import concurrent.futures
from queue import SimpleQueue
from types import MethodType from types import MethodType
from timeit import default_timer from timeit import default_timer
from typing import Iterable, Tuple from typing import Iterable, Tuple
import httpx import httpx
import anyio import anyio
import h2.exceptions
from .network import get_network, initialize, check_network_configuration from .network import get_network, initialize, check_network_configuration
from .client import get_loop from .client import get_loop
from .raise_for_httperror import raise_for_httperror from .raise_for_httperror import raise_for_httperror
# queue.SimpleQueue: Support Python 3.6
try:
from queue import SimpleQueue
except ImportError:
from queue import Empty
from collections import deque
class SimpleQueue:
"""Minimal backport of queue.SimpleQueue"""
def __init__(self):
self._queue = deque()
self._count = threading.Semaphore(0)
def put(self, item):
self._queue.append(item)
self._count.release()
def get(self):
if not self._count.acquire(True): # pylint: disable=consider-using-with
raise Empty
return self._queue.popleft()
THREADLOCAL = threading.local() THREADLOCAL = threading.local()
"""Thread-local data is data for thread specific values.""" """Thread-local data is data for thread specific values."""