From c436d7aa8df246dcb9e70a6a16fe558618c60d13 Mon Sep 17 00:00:00 2001 From: Bret Taylor Date: Mon, 11 Jan 2010 14:17:27 -0800 Subject: [PATCH] Fix new connection close handler for WSGI handlers --- tornado/web.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tornado/web.py b/tornado/web.py index 1c4b17a0..abe91266 100644 --- a/tornado/web.py +++ b/tornado/web.py @@ -92,8 +92,10 @@ class RequestHandler(object): self.ui["modules"] = _O((n, self._ui_module(n, m)) for n, m in application.ui_modules.iteritems()) self.clear() - self.request.connection.stream.set_close_callback( - self.on_connection_close) + # Check since connection is not available in WSGI + if hasattr(self.request, "connection"): + self.request.connection.stream.set_close_callback( + self.on_connection_close) @property def settings(self):