Skip to content

Commit

Permalink
httpx 0.28 support: use mounts instead od proxies
Browse files Browse the repository at this point in the history
I implemented transition as suggest in
encode/httpx#2879
  • Loading branch information
markotoplak committed Nov 29, 2024
1 parent 9ff3124 commit eb6b130
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 eb6b130

Please sign in to comment.