phytron: fix warning on repeated comm. error
log only a warning when several retries ware successful Change-Id: I2f1dfba920b0841914da82229820bcdd4b97c6e9
This commit is contained in:
parent
9f656546df
commit
e4aa2149f7
@ -35,7 +35,9 @@ class PhytronIO(StringIO):
|
||||
identification = [('0IVR', 'MCC Minilog .*')]
|
||||
|
||||
def communicate(self, command):
|
||||
for ntry in range(5, 0, -1):
|
||||
ntry = 5
|
||||
warn = None
|
||||
for itry in range(ntry):
|
||||
try:
|
||||
_, _, reply = super().communicate('\x02' + command).partition('\x02')
|
||||
if reply[0] == '\x06': # ACK
|
||||
@ -43,9 +45,12 @@ class PhytronIO(StringIO):
|
||||
raise CommunicationFailedError('missing ACK %r (cmd: %r)'
|
||||
% (reply, command))
|
||||
except Exception as e:
|
||||
if ntry == 1:
|
||||
if itry < ntry - 1:
|
||||
warn = e
|
||||
else:
|
||||
raise
|
||||
self.log.warning('%s - retry', e)
|
||||
if warn:
|
||||
self.log.warning('needed %d retries after %r', itry, warn)
|
||||
return reply[1:]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user