Skip to content

Commit

Permalink
Close wsgi responses correctly - the close method, if present, will
Browse files Browse the repository at this point in the history
be on the result of self.wsgi_application() and not on the list
of output we're building up.
  • Loading branch information
Ben Darnell committed Jun 18, 2010
1 parent 39ac6d1 commit df0d88e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tornado/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,12 @@ def start_response(status, response_headers, exc_info=None):
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])
Expand Down

0 comments on commit df0d88e

Please sign in to comment.