From be9ce4e4ffa418ba64612efdabee116dd59a6f5d Mon Sep 17 00:00:00 2001 From: Devaev Maxim Date: Thu, 4 Jun 2020 05:52:50 +0300 Subject: serial: decrease common_retries with read_retries --- kvmd/plugins/hid/serial.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'kvmd/plugins/hid/serial.py') diff --git a/kvmd/plugins/hid/serial.py b/kvmd/plugins/hid/serial.py index c41c762c..0af31eca 100644 --- a/kvmd/plugins/hid/serial.py +++ b/kvmd/plugins/hid/serial.py @@ -313,9 +313,9 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst def __process_request(self, tty: serial.Serial, request: bytes) -> None: # pylint: disable=too-many-branches logger = get_logger() + common_error_occured = False common_retries = self.__common_retries read_retries = self.__read_retries - error_occured = False while common_retries and read_retries: if not self.__noop: @@ -351,7 +351,7 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst self.__state_flags.update(online=True) return elif code == 0x20: # Done - if error_occured: + if common_error_occured: logger.info("Success!") self.__state_flags.update(online=True) return @@ -366,9 +366,8 @@ class Plugin(BaseHid, multiprocessing.Process): # pylint: disable=too-many-inst else: logger.error("Invalid response from HID: request=%r; code=0x%x", request, code) - common_retries -= 1 - - error_occured = True + common_error_occured = True + common_retries -= 1 self.__state_flags.update(online=False) if common_retries and read_retries: -- cgit v1.2.3