Skip to content

Commit

Permalink
catch an error on recv in librouteros and raise an error #8
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaae committed Mar 12, 2020
1 parent d9dd533 commit d68ffbd
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,13 @@ def read(self, length):
"""
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
Expand Down

0 comments on commit d68ffbd

Please sign in to comment.