catching socket.timeout using tuple exception #8

This commit is contained in:
tomaae 2020-03-13 02:39:35 +01:00
parent b20d140383
commit 0f7ad23e3c
2 changed files with 15 additions and 2 deletions

View file

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