diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-12-30 15:19:22 +0100 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-12-31 12:47:34 +0100 |
| commit | acc5396e6d0ac49ae9dc6abc08903b81e6553199 (patch) | |
| tree | a1a72a7fee149c874ca5005543a08b5eec9b4b68 /django/http | |
| parent | a53c4740268721036a6b3bc73f5e8f557c18bac0 (diff) | |
Fixed #19519 -- Fired request_finished in the WSGI iterable's close().
Diffstat (limited to 'django/http')
| -rw-r--r-- | django/http/response.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/django/http/response.py b/django/http/response.py index d667ba6eed..48a401adcb 100644 --- a/django/http/response.py +++ b/django/http/response.py @@ -10,6 +10,7 @@ except ImportError: from urlparse import urlparse from django.conf import settings +from django.core import signals from django.core import signing from django.core.exceptions import SuspiciousOperation from django.http.cookie import SimpleCookie @@ -40,6 +41,9 @@ class HttpResponseBase(six.Iterator): self._headers = {} self._charset = settings.DEFAULT_CHARSET self._closable_objects = [] + # This parameter is set by the handler. It's necessary to preserve the + # historical behavior of request_finished. + self._handler_class = None if mimetype: warnings.warn("Using mimetype keyword argument is deprecated, use" " content_type instead", @@ -226,7 +230,11 @@ class HttpResponseBase(six.Iterator): # See http://blog.dscpl.com.au/2012/10/obligations-for-calling-close-on.html def close(self): for closable in self._closable_objects: - closable.close() + try: + closable.close() + except Exception: + pass + signals.request_finished.send(sender=self._handler_class) def write(self, content): raise Exception("This %s instance is not writable" % self.__class__.__name__) |
