diff --git a/obsws_python/baseclient.py b/obsws_python/baseclient.py index 10e9d12..9bf8143 100644 --- a/obsws_python/baseclient.py +++ b/obsws_python/baseclient.py @@ -15,7 +15,7 @@ class ObsClient: logger = logging.getLogger("baseclient.obsclient") def __init__(self, **kwargs): - defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0} + defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0, "timeout":3} if not any(key in kwargs for key in ("host", "port", "password")): kwargs |= self._conn_from_toml() kwargs = defaultkwargs | kwargs @@ -29,7 +29,7 @@ class ObsClient: ) self.ws = websocket.WebSocket() - self.ws.connect(f"ws://{self.host}:{self.port}") + self.ws.connect(f"ws://{self.host}:{self.port}", timeout=self.timeout) self.server_hello = json.loads(self.ws.recv()) def _conn_from_toml(self) -> dict: @@ -105,7 +105,10 @@ class ObsClient: if req_data: payload["d"]["requestData"] = req_data self.logger.debug(f"Sending request {payload}") - self.ws.send(json.dumps(payload)) + try: + self.ws.send(json.dumps(payload)) + except TimeoutError: + raise OBSSDKError("Timeout while trying to send the request") response = json.loads(self.ws.recv()) self.logger.debug(f"Response received {response}") return response["d"] diff --git a/obsws_python/version.py b/obsws_python/version.py index 841aad2..8fb4690 100644 --- a/obsws_python/version.py +++ b/obsws_python/version.py @@ -1 +1 @@ -version = "1.4.2" +version = "1.4.3"