From b98889b54a5c13a333e6eb24fe289cb41c86cc6d Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Sat, 5 Mar 2016 15:47:49 -0500 Subject: [PATCH] Ensure correct inflight thread id is discarded It seems it is possible in some circumstance for the thread id to become stale, perhaps due to a different threadid executing the code for some reason. Just in case, ensure the same exact value that was added is later discarded. --- confluent_server/confluent/httpapi.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/confluent_server/confluent/httpapi.py b/confluent_server/confluent/httpapi.py index 5c015ff6..5560836a 100644 --- a/confluent_server/confluent/httpapi.py +++ b/confluent_server/confluent/httpapi.py @@ -422,15 +422,15 @@ def resourcehandler_backend(env, start_response): # add our thread to the 'inflight' to have a hook to terminate # a long polling request loggedout = None - httpsessions[authorized['sessionid']]['inflight'].add( - greenlet.getcurrent()) + mythreadid = greenlet.getcurrent() + httpsessions[authorized['sessionid']]['inflight'].add(mythreadid) try: outdata = consolesessions[sessid]['session'].get_next_output( timeout=25) except greenlet.GreenletExit as ge: loggedout = ge httpsessions[authorized['sessionid']]['inflight'].discard( - greenlet.getcurrent()) + mythreadid) if sessid not in consolesessions: start_response('400 Expired Session', headers) yield ''