mirror of
https://github.com/tomaae/homeassistant-mikrotik_router.git
synced 2025-07-05 15:04:30 +02:00
catch an error on recv in librouteros and raise an error #8
This commit is contained in:
parent
d9dd5330ee
commit
d68ffbdc46
1 changed files with 7 additions and 1 deletions
|
@ -22,7 +22,13 @@ class SocketTransport:
|
||||||
"""
|
"""
|
||||||
data = bytearray()
|
data = bytearray()
|
||||||
while len(data) != length:
|
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:
|
if not data:
|
||||||
raise ConnectionClosed('Connection unexpectedly closed.')
|
raise ConnectionClosed('Connection unexpectedly closed.')
|
||||||
return data
|
return data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue