Fix Tornado memory leak with synchronously handled requests.

The new Tornado handler tracking logic properly handled requests that
threw an exception or followed the RespondAsynchronously code path,
but did not properly de-allocated the handler in the syncronous case.

An easy reproducer for this is to load a new Zulip browser window;
that will leak 2 handler objects for the 2 synchronous requests made
from Django to Tornado as part of initial state fetching.
This commit is contained in:
Tim Abbott
2016-03-20 16:02:18 -07:00
parent 12a5a3a6e1
commit 3f55e26a9f

View File

@@ -244,6 +244,7 @@ class AsyncDjangoHandler(tornado.web.RequestHandler, base.BaseHandler):
if response is RespondAsynchronously:
async_request_stop(request)
return None
clear_handler_by_id(self.handler_id)
except Exception as e:
clear_handler_by_id(self.handler_id)
# If the view raised an exception, run it through exception