forked from zaclys/searxng
[fix] PR #257: use the image_proxy network instead of the default network
This commit is contained in:
parent
76e0f6807c
commit
2b53d718e4
|
@ -173,9 +173,17 @@ async def stream_chunk_to_queue(network, queue, method, url, **kwargs):
|
||||||
if len(chunk) > 0:
|
if len(chunk) > 0:
|
||||||
queue.put(chunk)
|
queue.put(chunk)
|
||||||
except httpx.ResponseClosed:
|
except httpx.ResponseClosed:
|
||||||
# the response was closed
|
# the response was queued before the exception.
|
||||||
|
# the exception was raised on aiter_raw.
|
||||||
|
# we do nothing here: in the finally block, None will be queued
|
||||||
|
# so stream(method, url, **kwargs) generator can stop
|
||||||
pass
|
pass
|
||||||
except (httpx.HTTPError, OSError, h2.exceptions.ProtocolError) as e:
|
except Exception as e: # pylint: disable=broad-except
|
||||||
|
# broad except to avoid this scenario:
|
||||||
|
# exception in network.stream(method, url, **kwargs)
|
||||||
|
# -> the exception is not catch here
|
||||||
|
# -> queue None (in finally)
|
||||||
|
# -> the function below steam(method, url, **kwargs) has nothing to return
|
||||||
queue.put(e)
|
queue.put(e)
|
||||||
finally:
|
finally:
|
||||||
queue.put(None)
|
queue.put(None)
|
||||||
|
@ -201,8 +209,9 @@ def stream(method, url, **kwargs):
|
||||||
the httpx.AsyncHTTPTransport declared above.
|
the httpx.AsyncHTTPTransport declared above.
|
||||||
"""
|
"""
|
||||||
queue = SimpleQueue()
|
queue = SimpleQueue()
|
||||||
|
network = get_context_network()
|
||||||
future = asyncio.run_coroutine_threadsafe(
|
future = asyncio.run_coroutine_threadsafe(
|
||||||
stream_chunk_to_queue(get_network(), queue, method, url, **kwargs),
|
stream_chunk_to_queue(network, queue, method, url, **kwargs),
|
||||||
get_loop()
|
get_loop()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue