From 64a7c2b7530b56db422ff59c2759a1e20b63f9ec Mon Sep 17 00:00:00 2001 From: Adem <34811741+aatikturk@users.noreply.github.com> Date: Wed, 14 Jun 2023 01:09:44 +0300 Subject: [PATCH] update readme and base client --- README.md | 2 +- obsws_python/baseclient.py | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fab24a0..46b8849 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ By default the clients connect with parameters: - `host`: "localhost" - `port`: 4455 - `password`: "" -- `timeout`: 3 + You may override these parameters by storing them in a toml config file or passing them as keyword arguments. Order of precedence: keyword arguments then config file then default values. diff --git a/obsws_python/baseclient.py b/obsws_python/baseclient.py index 9bf8143..17b85a0 100644 --- a/obsws_python/baseclient.py +++ b/obsws_python/baseclient.py @@ -7,7 +7,7 @@ from random import randint from typing import Optional import websocket - +from websocket._exceptions import WebSocketTimeoutException from .error import OBSSDKError @@ -15,7 +15,7 @@ class ObsClient: logger = logging.getLogger("baseclient.obsclient") def __init__(self, **kwargs): - defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0, "timeout":3} + defaultkwargs = {"host": "localhost", "port": 4455, "password": "", "subs": 0, "timeout":None} if not any(key in kwargs for key in ("host", "port", "password")): kwargs |= self._conn_from_toml() kwargs = defaultkwargs | kwargs @@ -107,8 +107,8 @@ class ObsClient: self.logger.debug(f"Sending request {payload}") try: self.ws.send(json.dumps(payload)) - except TimeoutError: + response = json.loads(self.ws.recv()) + except WebSocketTimeoutException : 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"]