From e5f7fcc339271b56c32aca2d83e63266def6d5e3 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Wed, 29 Apr 2015 11:18:51 +0800 Subject: [PATCH] coredevice/comm_tcp: raise exception on connection closed --- artiq/coredevice/comm_tcp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/artiq/coredevice/comm_tcp.py b/artiq/coredevice/comm_tcp.py index bce17fea3..4cc254a10 100644 --- a/artiq/coredevice/comm_tcp.py +++ b/artiq/coredevice/comm_tcp.py @@ -30,7 +30,10 @@ class Comm(CommGeneric, AutoDB): def read(self, length): r = bytes() 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 def write(self, data):