diff options
| author | Alexandre Flament <alex@al-f.net> | 2021-04-27 20:06:54 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-27 20:06:54 +0200 |
| commit | b06a15376c546bb216ed7fa5e8f2f8b793420f33 (patch) | |
| tree | b57413a1b766d08e6f40aebe2a166c564fa26213 /searx/network/__init__.py | |
| parent | f724d6f6f1a38d11bc26c39648441bc8788b4288 (diff) | |
| parent | 283ae7bfad05fedbf6c7a7e7d7addfc3ae7ed9c7 (diff) | |
Merge pull request #32 from searxng/fix-network
[fix] searx.network: fix rare cases where LOOP is None
Diffstat (limited to 'searx/network/__init__.py')
| -rw-r--r-- | searx/network/__init__.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/searx/network/__init__.py b/searx/network/__init__.py index 40665f7d6..981b2261a 100644 --- a/searx/network/__init__.py +++ b/searx/network/__init__.py @@ -9,7 +9,7 @@ import httpx import h2.exceptions from .network import get_network, initialize -from .client import LOOP +from .client import get_loop from .raise_for_httperror import raise_for_httperror # queue.SimpleQueue: Support Python 3.6 @@ -98,7 +98,7 @@ def request(method, url, **kwargs): network = get_context_network() # do request - future = asyncio.run_coroutine_threadsafe(network.request(method, url, **kwargs), LOOP) + future = asyncio.run_coroutine_threadsafe(network.request(method, url, **kwargs), get_loop()) try: response = future.result(timeout) except concurrent.futures.TimeoutError as e: @@ -179,7 +179,7 @@ def stream(method, url, **kwargs): """ q = SimpleQueue() future = asyncio.run_coroutine_threadsafe(stream_chunk_to_queue(get_network(), q, method, url, **kwargs), - LOOP) + get_loop()) chunk_or_exception = q.get() while chunk_or_exception is not None: if isinstance(chunk_or_exception, Exception): |