reduce logging of communication error messages

Change-Id: I2de62c023327160ffeba2813d652ae340c7f6de0
This commit is contained in:
zolliker committed 2026-09-15 15:43:49 +02:00
1 parent 71495aa934
commit 522c99e3a2
1 file changed
+24 -15
+24 -15
View File
@@ -126,7 +126,8 @@ class IOBase(Communicator):
_reconnectCallbacks = None
_conn = None
_last_error = None # this is None only until the first connection success
_last_error = None # the last error (or a success state)
# _last_error is None only until the first connection success
_lock = None
_last_connect_attempt = 0
@@ -349,14 +350,15 @@ class StringIO(IOBase):
self.comLog('< %s', reply)
return reply
except Exception as e:
new_error = 'disconnected' if self._conn is None else repr(e)
not_severe = isinstance(e, SECoPError)
if self._conn is None:
new_error = 'disconnected'
e = None
else:
new_error = repr(e)
if new_error != self._last_error:
# suppress subsequent equal error messages
# this is in addition to the mechanism in Module.callPollFunc
# as the same error would appear potentially in a lot of
# methods
if isinstance(e, SECoPError):
self.log.error(new_error)
if not_severe:
self.log.error('%s -> %s', self._last_error, new_error)
else:
self.log.exception(new_error)
raise SilentError(new_error) from e
@@ -456,6 +458,12 @@ class StringIO(IOBase):
self.log.error(self._last_error)
raise SilentError(repr(e)) from e
@Command
def reconnect(self):
"""close and open connection"""
self.closeConnection()
self.read_is_connected()
def make_regexp(string):
"""create a bytes regexp pattern from a string describing a bytes pattern
@@ -538,14 +546,15 @@ class BytesIO(IOBase):
self.comLog('< %s', hexify(reply))
return self.getFullReply(request, reply)
except Exception as e:
new_error = 'disconnected' if self._conn is None else repr(e)
not_severe = isinstance(e, SECoPError)
if self._conn is None:
new_error = 'disconnected'
e = None
else:
new_error = repr(e)
if new_error != self._last_error:
# suppress subsequent equal error messages
# this is in addition to the mechanism in Module.callPollFunc
# as the same error would appear potentially in a lot of
# methods
if isinstance(e, SECoPError):
self.log.error(new_error)
if not_severe:
self.log.error('%s -> %s', self._last_error, new_error)
else:
self.log.exception(new_error)
raise SilentError(new_error) from e