From: Ben Darnell Date: Fri, 18 Jun 2010 22:59:19 +0000 (-0700) Subject: Close wsgi responses correctly - the close method, if present, will X-Git-Tag: v1.0.0~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df0d88eb8d3eef5f2fe351676ef1500e115e3131;p=thirdparty%2Ftornado.git Close wsgi responses correctly - the close method, if present, will be on the result of self.wsgi_application() and not on the list of output we're building up. --- diff --git a/tornado/wsgi.py b/tornado/wsgi.py index 181429cb3..4aaa5fb73 100644 --- a/tornado/wsgi.py +++ b/tornado/wsgi.py @@ -219,11 +219,12 @@ class WSGIContainer(object): data["status"] = status data["headers"] = response_headers return response.append - response.extend(self.wsgi_application( - WSGIContainer.environ(request), start_response)) + app_response = self.wsgi_application( + WSGIContainer.environ(request), start_response) + response.extend(app_response) body = "".join(response) - if hasattr(response, "close"): - response.close() + if hasattr(app_response, "close"): + app_response.close() if not data: raise Exception("WSGI app did not call start_response") status_code = int(data["status"].split()[0])