From c7bb73d77a0e470fe55011b5bbb3f7a18be1544f Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Sat, 22 Jun 2024 14:58:58 +0200 Subject: [PATCH 1/9] Update risco_socket.py Adjusted communication delay from 0 to 1 --- pyrisco/local/risco_socket.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrisco/local/risco_socket.py b/pyrisco/local/risco_socket.py index 30f7d28..b00f215 100644 --- a/pyrisco/local/risco_socket.py +++ b/pyrisco/local/risco_socket.py @@ -12,7 +12,7 @@ def __init__(self, host, port, code, **kwargs): self._code = code self._encoding = kwargs.get('encoding', 'utf-8') self._max_concurrency = kwargs.get('concurrency', 4) - self._communication_delay = kwargs.get('communication_delay', 0) + self._communication_delay = kwargs.get('communication_delay', 1) self._reader = None self._writer = None self._crypt = None From cfd362ea80909e304f562de74c79e78d544f046c Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:19:00 +0200 Subject: [PATCH 2/9] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index b48d83c..de89409 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ EMAIL = 'onfreund@gmail.com' AUTHOR = 'On Freund' REQUIRES_PYTHON = '>=3.7.0' -VERSION = '0.6.4' +VERSION = '0.66.5' REQUIRED = ['aiohttp'] From 5ed1618a5acde4b51ae6b29b3eea327b909c71cf Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:34:09 +0200 Subject: [PATCH 3/9] Update risco_socket.py --- pyrisco/local/risco_socket.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/pyrisco/local/risco_socket.py b/pyrisco/local/risco_socket.py index b00f215..3bc9b13 100644 --- a/pyrisco/local/risco_socket.py +++ b/pyrisco/local/risco_socket.py @@ -1,6 +1,6 @@ import asyncio from .risco_crypt import RiscoCrypt, ESCAPED_END, END -from pyrisco.common import UnauthorizedError, CannotConnectError, OperationError +from pyrisco.common import UnauthorizedError, CannotConnectError, ConnectionError, OperationError MIN_CMD_ID = 1 MAX_CMD_ID = 49 @@ -13,6 +13,7 @@ def __init__(self, host, port, code, **kwargs): self._encoding = kwargs.get('encoding', 'utf-8') self._max_concurrency = kwargs.get('concurrency', 4) self._communication_delay = kwargs.get('communication_delay', 1) + self._max_timeout_keep_alive_subseq = kwargs.get('max_timeout_subseq', 3) self._reader = None self._writer = None self._crypt = None @@ -89,8 +90,19 @@ async def _keep_alive(self): try: await self.send_result_command("CLOCK") except OperationError as error: - await self._queue.put(error) - + timeout_keep_alive_subseq += 1 + try: + if self._max_timeout_keep_alive_subseq > 0: + if timeout_keep_alive_subseq >= self._max_timeout_keep_alive_subseq: + raise ConnectionError + except Exception as error: + await self._queue.put(error) + break + else: + await self._queue.put(error) + else: + timeout_keep_alive_subseq = 0 + await asyncio.sleep(5) async def send_ack_command(self, command): From 749bc87680373dda082db056945bd248ebe2f76d Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:36:13 +0200 Subject: [PATCH 4/9] Update common.py --- pyrisco/common.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pyrisco/common.py b/pyrisco/common.py index a0e46dc..f887a7c 100644 --- a/pyrisco/common.py +++ b/pyrisco/common.py @@ -140,6 +140,8 @@ class UnauthorizedError(Exception): class CannotConnectError(Exception): """Exception to indicate an error in authorization.""" +class ConnectionError(Exception): + """Exception to indicate an error with the connection.""" class OperationError(Exception): """Exception to indicate an error in operation.""" From a26aefd07e6e715fe99493eddda4fe38fce4a28a Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:37:57 +0200 Subject: [PATCH 5/9] Update risco_local.py --- pyrisco/local/risco_local.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pyrisco/local/risco_local.py b/pyrisco/local/risco_local.py index 00f740d..66566ff 100644 --- a/pyrisco/local/risco_local.py +++ b/pyrisco/local/risco_local.py @@ -6,7 +6,7 @@ from .zone import Zone from .system import System from .risco_socket import RiscoSocket -from pyrisco.common import OperationError, GROUP_ID_TO_NAME +from pyrisco.common import OperationError, ConnectionError, GROUP_ID_TO_NAME class RiscoLocal: @@ -204,7 +204,7 @@ async def _listen(self, queue): item = await queue.get() if isinstance(item, Exception): self._error(item) - if isinstance(item, ConnectionResetError): + if isinstance(item, ConnectionError): await self.disconnect() break continue From 46e1c097f7162cef5ae3ba07c850fe669c78e4e1 Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:56:23 +0200 Subject: [PATCH 6/9] Update __init__.py --- pyrisco/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyrisco/__init__.py b/pyrisco/__init__.py index 0587c40..2c9c1df 100644 --- a/pyrisco/__init__.py +++ b/pyrisco/__init__.py @@ -1,3 +1,3 @@ from pyrisco.local import RiscoLocal from pyrisco.cloud import RiscoCloud -from .common import CannotConnectError, OperationError, UnauthorizedError +from .common import CannotConnectError, ConnectionError, OperationError, UnauthorizedError From 16604f4dd22c0629f5f6cc5a2e136e76a9748a41 Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Mon, 24 Jun 2024 21:56:43 +0200 Subject: [PATCH 7/9] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index de89409..5054a53 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ EMAIL = 'onfreund@gmail.com' AUTHOR = 'On Freund' REQUIRES_PYTHON = '>=3.7.0' -VERSION = '0.66.5' +VERSION = '0.66.6' REQUIRED = ['aiohttp'] From 35cf761f912fbf300655b4967a75e141ad61b801 Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Thu, 27 Jun 2024 20:56:03 +0200 Subject: [PATCH 8/9] Update risco_socket.py --- pyrisco/local/risco_socket.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pyrisco/local/risco_socket.py b/pyrisco/local/risco_socket.py index 3bc9b13..59f0771 100644 --- a/pyrisco/local/risco_socket.py +++ b/pyrisco/local/risco_socket.py @@ -78,9 +78,6 @@ async def _listen(self): future.set_result(command) else: await self._handle_incoming(cmd_id, command, crc) - except ConnectionResetError as error: - await self._queue.put(error) - break except Exception as error: await self._queue.put(error) From a26c5f4707f340b67bb3555c5565d1b974885e21 Mon Sep 17 00:00:00 2001 From: jakob1911 <112578977+jakob1911@users.noreply.github.com> Date: Thu, 27 Jun 2024 20:58:13 +0200 Subject: [PATCH 9/9] Update setup.py --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5054a53..bc79e64 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ EMAIL = 'onfreund@gmail.com' AUTHOR = 'On Freund' REQUIRES_PYTHON = '>=3.7.0' -VERSION = '0.66.6' +VERSION = '0.6.5' REQUIRED = ['aiohttp']