mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-06-06 13:30:41 +02:00
fix: using client without aiohttp_socks dependency does not raise
When not specifying the proxy_url in `pydase.Client`, the aiohttp_socks dependency is not required. This is now handled by putting the import into the correct place, adding a descriptive log message when the import fails.
This commit is contained in:
parent
069a2b4696
commit
6c2cebada2
@ -1,3 +1,4 @@
|
||||
from builtins import ModuleNotFoundError
|
||||
import asyncio
|
||||
import logging
|
||||
import sys
|
||||
@ -7,7 +8,6 @@ from types import TracebackType
|
||||
from typing import TYPE_CHECKING, Any, TypedDict, cast
|
||||
|
||||
import aiohttp
|
||||
import aiohttp_socks.connector
|
||||
import socketio # type: ignore
|
||||
|
||||
from pydase.client.proxy_class import ProxyClass
|
||||
@ -150,6 +150,17 @@ class Client:
|
||||
|
||||
def _initialize_socketio_client(self) -> None:
|
||||
if self._proxy_url is not None:
|
||||
try:
|
||||
import aiohttp_socks.connector
|
||||
except ModuleNotFoundError:
|
||||
raise ModuleNotFoundError(
|
||||
"Missing dependency 'aiohttp_socks'. To use SOCKS5 proxy support, "
|
||||
"install the optional 'socks' extra:\n\n"
|
||||
' pip install "pydase[socks]"\n\n'
|
||||
"This is required when specifying a `proxy_url` for "
|
||||
"`pydase.Client`."
|
||||
)
|
||||
|
||||
session = aiohttp.ClientSession(
|
||||
connector=aiohttp_socks.connector.ProxyConnector.from_url(
|
||||
url=self._proxy_url, loop=self._loop
|
||||
|
Loading…
x
Reference in New Issue
Block a user