Skip to content

Commit

Permalink
wsgi: ensure to close the app response iterator (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Jan 16, 2023
1 parent ed0e12a commit e9925c9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions granian/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,13 @@ def start_response(
resp.headers = headers

rv = callback(environ, start_response)
body = b"".join(rv)
if hasattr(rv, "close"):
rv.close()

try:
body = b"".join(rv)
finally:
if hasattr(rv, "close"):
rv.close()

return (resp.status, resp.headers, body)

return wrapper

0 comments on commit e9925c9

Please sign in to comment.