improve error handling on client connections

- send a heartbeat, if no events for 5 sec.
  an interrupted connection (not closed by the other end) may
  not be detected for a long time when nothing is sent
+ make the error reply on a non SECoPEror more verbose
  e.g. "KeyError('foo')" instead of just "foo"
+ allow cfg file without nodeinterface
+ shorter logger name in HasIodev

Change-Id: I6b1ff23f9bf8c96feb25af44935596437b7d726f
Reviewed-on: https://forge.frm2.tum.de/review/c/sine2020/secop/playground/+/23098
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Markus Zolliker <markus.zolliker@psi.ch>
This commit is contained in:
2020-05-15 14:21:34 +02:00
parent 5c33cbf7a5
commit 7953826fac
5 changed files with 23 additions and 8 deletions

View File

@ -159,14 +159,20 @@ class AsynTcp(AsynConn):
return b''.join(data)
def recv(self):
"""return bytes received within 1 sec"""
"""return bytes in the recv buffer
or bytes received within 1 sec
"""
try:
data = self.connection.recv(8192)
if data:
return data
except socket.timeout:
except (socket.timeout, TimeoutError):
# timeout while waiting
return b''
# note that when no data is sent on a connection, an interruption might
# not be detected within a reasonable time. sending a heartbeat should
# help in this case.
raise ConnectionClosed() # marks end of connection