From ee1593b77c5ffdfa7102a66eb9f3239e5f8370b6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 28 Oct 2015 08:06:09 +0530 Subject: [PATCH] ... --- src/calibre/srv/loop.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/calibre/srv/loop.py b/src/calibre/srv/loop.py index 93975fd8a1..c37a03a852 100644 --- a/src/calibre/srv/loop.py +++ b/src/calibre/srv/loop.py @@ -560,7 +560,11 @@ class ServerLoop(object): else: yield s, self.connection_map[s], READ for s in writable: - yield s, self.connection_map[s], WRITE + try: + conn = self.connection_map[s] + except KeyError: + continue # Happens if connection was closed during read phase + yield s, conn, WRITE def accept(self): try: