Ticket #19519: fix_19519.diff

File fix_19519.diff, 1.6 KB (added by apollo13, 2 years ago)
  • django/core/handlers/wsgi.py

    diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
    index 426679c..47f111d 100644
    a b import codecs 
    44import logging
    55import sys
    66from io import BytesIO
     7from functools import partial
    78from threading import Lock
    89
    910from django import http
    class WSGIHandler(base.BaseHandler): 
    254255        else:
    255256            response = self.get_response(request)
    256257        finally:
    257             signals.request_finished.send(sender=self.__class__)
     258            cb = partial(signals.request_finished.send, sender=self.__class__)
     259            response._on_close_callbacks.append(cb)
    258260
    259261        try:
    260262            status_text = STATUS_CODE_TEXT[response.status_code]
  • django/http/response.py

    diff --git a/django/http/response.py b/django/http/response.py
    index df0a955..e294fda 100644
    a b class HttpResponseBase(six.Iterator): 
    4040        self._headers = {}
    4141        self._charset = settings.DEFAULT_CHARSET
    4242        self._closable_objects = []
     43        self._on_close_callbacks = []
    4344        if mimetype:
    4445            warnings.warn("Using mimetype keyword argument is deprecated, use"
    4546                          " content_type instead", PendingDeprecationWarning)
    class HttpResponseBase(six.Iterator): 
    226227    def close(self):
    227228        for closable in self._closable_objects:
    228229            closable.close()
     230        for callback in self._on_close_callbacks:
     231            callback()
    229232
    230233    def write(self, content):
    231234        raise Exception("This %s instance is not writable" % self.__class__.__name__)
Back to Top