Skip to content

Commit

Permalink
Merge pull request #6943 from markotoplak/httpx-proxies
Browse files Browse the repository at this point in the history
[FIX] httpx 0.28 support: use mounts instead of proxies
  • Loading branch information
janezd authored Nov 29, 2024
2 parents 9ff3124 + eb6b130 commit cc50f6e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions Orange/misc/server_embedder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit cc50f6e

Please sign in to comment.