From e0c42079849f8a0adb0f0d317534a98983e7f908 Mon Sep 17 00:00:00 2001 From: lucasheld Date: Fri, 23 Dec 2022 14:07:46 +0100 Subject: [PATCH] feat: add parameter `wait_timeout` to adjust connection timeout --- uptime_kuma_api/api.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/uptime_kuma_api/api.py b/uptime_kuma_api/api.py index a303379..333496c 100644 --- a/uptime_kuma_api/api.py +++ b/uptime_kuma_api/api.py @@ -300,10 +300,16 @@ class UptimeKumaApi(object): >>> api.disconnect() :param str url: The url to the Uptime Kuma instance. For example ``http://127.0.0.1:3001`` + :param float wait_timeout: How many seconds the client should wait for the connection., defaults to 1 :raises UptimeKumaException: When connection to server failed. """ - def __init__(self, url: str) -> None: + def __init__( + self, + url: str, + wait_timeout: float = 1 + ) -> None: self.url = url + self.wait_timeout = wait_timeout self.sio = socketio.Client() self._event_data: dict = { @@ -465,7 +471,7 @@ class UptimeKumaApi(object): """ url = self.url.rstrip("/") try: - self.sio.connect(f'{url}/socket.io/') + self.sio.connect(f'{url}/socket.io/', wait_timeout=self.wait_timeout) except: raise UptimeKumaException("unable to connect")