|
|
|
@ -5,41 +5,18 @@
|
|
|
|
|
import asyncio
|
|
|
|
|
import threading
|
|
|
|
|
import concurrent.futures
|
|
|
|
|
from queue import SimpleQueue
|
|
|
|
|
from types import MethodType
|
|
|
|
|
from timeit import default_timer
|
|
|
|
|
from typing import Iterable, Tuple
|
|
|
|
|
|
|
|
|
|
import httpx
|
|
|
|
|
import anyio
|
|
|
|
|
import h2.exceptions
|
|
|
|
|
|
|
|
|
|
from .network import get_network, initialize, check_network_configuration
|
|
|
|
|
from .client import get_loop
|
|
|
|
|
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()
|
|
|
|
|
"""Thread-local data is data for thread specific values."""
|
|
|
|
|