From 234d6acf4f60be2371ab9d207eb781ded2a23360 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 16 Oct 2014 13:29:57 -0400 Subject: notice closed connections when we try to read --- termcast_server/termcast.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/termcast_server/termcast.py b/termcast_server/termcast.py index a2318d6..1bb6d15 100644 --- a/termcast_server/termcast.py +++ b/termcast_server/termcast.py @@ -229,7 +229,10 @@ class Connection(object): def _readline(self): buf = b'' while len(buf) < 1024 and b"\n" not in buf: - buf += self.client.recv(1) + byte = self.client.recv(1) + if len(byte) == 0: + raise Exception("Connection closed unexpectedly") + buf += byte pos = buf.find(b"\n") if pos == -1: -- cgit v1.2.3