Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[1.5.x] Fixed #16241 -- Ensured the WSGI iterable's close() is always…

… called.

Thanks Graham Dumpleton for the report.

Backport of a53c474.
  • Loading branch information...
commit ac72782e61a8e08381cb66005295a4c24ed37f33 1 parent 814c3b2
@aaugustin aaugustin authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 django/core/servers/basehttp.py
View
11 django/core/servers/basehttp.py
@@ -109,6 +109,17 @@ def error_output(self, environ, start_response):
super(ServerHandler, self).error_output(environ, start_response)
return ['\n'.join(traceback.format_exception(*sys.exc_info()))]
+ # Backport of http://hg.python.org/cpython/rev/d5af1b235dab. See #16241.
+ # This can be removed when support for Python <= 2.7.3 is deprecated.
+ def finish_response(self):
+ try:
+ if not self.result_is_file() or not self.sendfile():
+ for data in self.result:
+ self.write(data)
+ self.finish_content()
+ finally:
+ self.close()
+
class WSGIServer(simple_server.WSGIServer, object):
"""BaseHTTPServer that implements the Python WSGI protocol"""
Please sign in to comment.
Something went wrong with that request. Please try again.