forked from M-Labs/artiq
1
0
Fork 0

coredevice/comm_tcp: raise exception on connection closed

This commit is contained in:
Sebastien Bourdeauducq 2015-04-29 11:18:51 +08:00
parent 283695e8aa
commit e5f7fcc339
1 changed files with 4 additions and 1 deletions

View File

@ -30,7 +30,10 @@ class Comm(CommGeneric, AutoDB):
def read(self, length): def read(self, length):
r = bytes() r = bytes()
while len(r) < length: while len(r) < length:
r += self.socket.recv(min(8192, length - len(r))) rn = self.socket.recv(min(8192, length - len(r)))
if not rn:
raise IOError("Connection closed")
r += rn
return r return r
def write(self, data): def write(self, data):