From 03b2cdab5a5c2cb5c12d7fbfb29b39f441119ac3 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 26 Mar 2016 10:26:17 -0400 Subject: [PATCH] Assure console sessions get reaped When an error (to be fixed) happened while updating expiry, an asyncsession failed to have a reaper scheduled for cleanup. Correct this by putting the reaper schedule right after the cancellation. Further, an async being destroyed did not reap related console sessions. Add code to reap related console sessions when the async session gets destroyed. --- confluent_server/confluent/asynchttp.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/confluent_server/confluent/asynchttp.py b/confluent_server/confluent/asynchttp.py index 24c51a8b..f109377c 100644 --- a/confluent_server/confluent/asynchttp.py +++ b/confluent_server/confluent/asynchttp.py @@ -104,6 +104,9 @@ class AsyncSession(object): if self._evt: self._evt.send() self._evt = None + for console in self.consoles: + _consolesessions[console]['session'].destroy() + self.consoles = None del _asyncsessions[self.asyncid] def run_handler(self, handler, requestid): @@ -113,10 +116,10 @@ class AsyncSession(object): def get_responses(self, timeout=25): 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 - self.reaper = eventlet.spawn_after(timeout + 15, self.destroy) if self._evt: # TODO(jjohnson2): This precludes the goal of 'double barreled' # access.... revisit if this could matter