From 029c06cc6691e9778779a44421f591ed178e9413 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 27 Feb 2016 13:37:10 -0500 Subject: [PATCH] Have polling consoleserver sessions more robustly clean up If anything goes wrong or a session was exited, no destruction of the session would be scheduled. Always have a reaper scheduled for that. --- confluent_server/confluent/consoleserver.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/consoleserver.py b/confluent_server/confluent/consoleserver.py index 09b4c0a1..61a6c14e 100644 --- a/confluent_server/confluent/consoleserver.py +++ b/confluent_server/confluent/consoleserver.py @@ -560,6 +560,8 @@ class ConsoleSession(object): instead of polling mode. """ self.reaper.cancel() + # postpone death to be 15 seconds after this would timeout + self.reaper = eventlet.spawn_after(timeout + 15, self.destroy) if self._evt: raise Exception('get_next_output is not re-entrant') if not self.databuffer: @@ -568,16 +570,12 @@ class ConsoleSession(object): self._evt.wait() self._evt = None if not self.databuffer: - self.reaper = eventlet.spawn_after(15, self.destroy) return "" currdata = self.databuffer.popleft() if isinstance(currdata, dict): - self.reaper = eventlet.spawn_after(15, self.destroy) return currdata retval = currdata while self.databuffer and not isinstance(self.databuffer[0], dict): retval += self.databuffer.popleft() - # the client has 15 seconds to make a new request for data before - # they are given up on - self.reaper = eventlet.spawn_after(15, self.destroy) + return retval