Skip to content

Commit 4293a2c

Browse files
authored
Merge pull request #1090 from markotoplak/proxies-mounts
[FIX] import_documents: rewrite proxies to mounts for httpx 0.28
2 parents 8b717fe + a2f12fb commit 4293a2c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

orangecontrib/text/import_documents.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,12 @@ def quote_byte(b):
178178
ResponseType = Tuple[Optional[Reader], Optional[TextData], Optional[str]]
179179

180180

181+
def _rewrite_proxies_to_mounts(proxies):
182+
if proxies is None:
183+
return None
184+
return {c: httpx.AsyncHTTPTransport(proxy=url) for c, url in get_proxies().items()}
185+
186+
181187
class UrlProxyReader:
182188
"""
183189
A collection of functions to handle async downloading of a list of documents
@@ -208,7 +214,8 @@ def read_files(
208214

209215
@staticmethod
210216
async def _read_files(urls: List[str], callback: Callable) -> List[ResponseType]:
211-
async with httpx.AsyncClient(timeout=10.0, proxies=get_proxies()) as client:
217+
proxy_mounts = _rewrite_proxies_to_mounts(get_proxies())
218+
async with httpx.AsyncClient(timeout=10.0, mounts=proxy_mounts) as client:
212219
req = [UrlProxyReader._read_file(url, client, callback) for url in urls]
213220
return await asyncio.gather(*req)
214221

0 commit comments

Comments
 (0)