1

I use StreamingHttpResponse in django framework. I want to save some records in database after response finished and connection closed. What should I do?

class foo(View):
    def get(self, request):
        response = StreamingHttpResponse(self._load_stream(request))
        return response

    def _load_stream(self, request):
        yield('<html><body></body></html>')
        time.sleep(5000)
        # close the connection and then save something to database
        
mohammad
  • 434
  • 1
  • 5
  • 17
  • You can put some logic at bottom of `_load_stream()` method/function, can't you? – JPG Dec 21 '20 at 10:36
  • @ArakkalAbu I can't. because it takes time to run the logic so I want to close the connection at first and then write my logic. – mohammad Dec 21 '20 at 12:50

0 Answers0