mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
updates pydase.Client documentation and constructor arguments
This commit is contained in:
parent
5eeaefdd63
commit
7b06786307
@ -38,20 +38,34 @@ class ProxyClass(ProxyClassMixin, pydase.components.DeviceConnection):
|
|||||||
|
|
||||||
class Client:
|
class Client:
|
||||||
"""
|
"""
|
||||||
|
A client for connecting to a remote pydase service using socket.io. This client
|
||||||
|
handles asynchronous communication with a service, manages events such as
|
||||||
|
connection, disconnection, and updates, and ensures that the proxy object is
|
||||||
|
up-to-date with the server state.
|
||||||
|
|
||||||
|
Attributes:
|
||||||
|
proxy (ProxyClass):
|
||||||
|
A proxy object representing the remote service, facilitating interaction as
|
||||||
|
if it were local.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
hostname: str
|
hostname (str):
|
||||||
Hostname of the exposed service this client attempts to connect to.
|
Hostname of the exposed service this client attempts to connect to.
|
||||||
Default: "localhost"
|
Default is "localhost".
|
||||||
port: int
|
port (int):
|
||||||
Port of the exposed service this client attempts to connect on.
|
Port of the exposed service this client attempts to connect on.
|
||||||
Default: 8001
|
Default is 8001.
|
||||||
blocking: bool
|
block_until_connected (bool):
|
||||||
If the constructor should wait until the connection to the service has been
|
If set to True, the constructor will block until the connection to the
|
||||||
established. Default: True
|
service has been established. This is useful for ensuring the client is
|
||||||
|
ready to use immediately after instantiation. Default is True.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self, hostname: str = "localhost", port: int = 8001, blocking: bool = True
|
self,
|
||||||
|
hostname: str,
|
||||||
|
port: int,
|
||||||
|
block_until_connected: bool = True,
|
||||||
):
|
):
|
||||||
self._hostname = hostname
|
self._hostname = hostname
|
||||||
self._port = port
|
self._port = port
|
||||||
@ -65,7 +79,7 @@ class Client:
|
|||||||
connection_future = asyncio.run_coroutine_threadsafe(
|
connection_future = asyncio.run_coroutine_threadsafe(
|
||||||
self._connect(), self._loop
|
self._connect(), self._loop
|
||||||
)
|
)
|
||||||
if blocking:
|
if block_until_connected:
|
||||||
connection_future.result()
|
connection_future.result()
|
||||||
|
|
||||||
async def _connect(self) -> None:
|
async def _connect(self) -> None:
|
||||||
|
@ -39,7 +39,7 @@ def pydase_client() -> Generator[pydase.Client, None, Any]:
|
|||||||
thread = threading.Thread(target=server.run, daemon=True)
|
thread = threading.Thread(target=server.run, daemon=True)
|
||||||
thread.start()
|
thread.start()
|
||||||
|
|
||||||
client = pydase.Client(port=9999)
|
client = pydase.Client(hostname="localhost", port=9999)
|
||||||
|
|
||||||
yield client
|
yield client
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user