From 417e70e5c1e13c6d3fb171d93a1bdd0d3af6314b Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 26 Mar 2016 10:45:47 -0400 Subject: [PATCH] Tolerate terminal closure When a terminal closes and notifies server, it was pulling the rug out from asyncsession consoles. Make asyncsession aware that the console may be gone and discard tracking it rather than give a 500. --- confluent_server/confluent/asynchttp.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/confluent_server/confluent/asynchttp.py b/confluent_server/confluent/asynchttp.py index f109377c..ab12c9be 100644 --- a/confluent_server/confluent/asynchttp.py +++ b/confluent_server/confluent/asynchttp.py @@ -118,8 +118,11 @@ class AsyncSession(object): self.reaper.cancel() self.reaper = eventlet.spawn_after(timeout + 15, self.destroy) nextexpiry = time.time() + 90 - for csess in self.consoles: - _consolesessions[csess]['expiry'] = nextexpiry + for csess in list(self.consoles): + try: + _consolesessions[csess]['expiry'] = nextexpiry + except KeyError: # session has been closed elsewhere + self.consoles.discard(csess) if self._evt: # TODO(jjohnson2): This precludes the goal of 'double barreled' # access.... revisit if this could matter