diff --git a/Orange/misc/server_embedder.py b/Orange/misc/server_embedder.py index c8f9d795258..4141c925f80 100644 --- a/Orange/misc/server_embedder.py +++ b/Orange/misc/server_embedder.py @@ -9,7 +9,7 @@ from typing import Any, Callable, List, Optional, Dict, Union from AnyQt.QtCore import QSettings -from httpx import AsyncClient, NetworkError, ReadTimeout, Response +from httpx import AsyncClient, NetworkError, ReadTimeout, Response, AsyncHTTPTransport from numpy import linspace from Orange.misc.utils.embedder_utils import ( @@ -23,6 +23,12 @@ TaskItem = namedtuple("TaskItem", ("id", "item", "no_repeats")) +def _rewrite_proxies_to_mounts(proxies): + if proxies is None: + return None + return {c: AsyncHTTPTransport(proxy=url) for c, url in get_proxies().items()} + + class ServerEmbedderCommunicator: """ This class needs to be inherited by the class which re-implements @@ -154,8 +160,10 @@ def success_callback(): for i, item in enumerate(data): queue.put_nowait(TaskItem(id=i, item=item, no_repeats=0)) + proxy_mounts = _rewrite_proxies_to_mounts(get_proxies()) + async with AsyncClient( - timeout=self.timeout, base_url=self.server_url, proxies=get_proxies() + timeout=self.timeout, base_url=self.server_url, mounts=proxy_mounts ) as client: tasks = self._init_workers(client, queue, results, success_callback)