catch an error on recv in librouteros and raise an error #8

This commit is contained in:
tomaae 2020-03-12 13:21:03 +01:00
parent d9dd5330ee
commit d68ffbdc46

View file

@ -22,7 +22,13 @@ class SocketTransport:
"""
data = bytearray()
while len(data) != length:
data += self.sock.recv((length - len(data)))
try:
tmp = self.sock.recv((length - len(data)))
except:
raise ConnectionClosed('Socket recv failed.')
finally:
data += tmp
if not data:
raise ConnectionClosed('Connection unexpectedly closed.')
return data