why there is no response_finished signal in Django?
-
20-06-2021 - |
Domanda
I am trying to implement some kind of background task queue in Django, because Celery is too huge & complex, then it occured to me that, there is already a signal called request_finished
https://docs.djangoproject.com/en/dev/ref/signals/#django.core.signals.request_finished
But why Django do not have a signal called response_finished
?
Django may be synchronous, but I can do some post-response data processing and saving tasks, it only taks few more steps.
Is hacking a way to do some post-response work possible in Django?
TIA
Soluzione 2
since no one answers this, I have some conclusions myself
https://groups.google.com/d/topic/python-web-sig/OEahWtsPwq4/discussion
It's basically a wsgi design behavior. Wsgi will not care what happens after respons iterator stops.
Altri suggerimenti
You can write your own middleware (specifically using process_response
) if you need to perform tasks after the response has been assembled. There would be no point in having a signal handler after the response is 'finished' as by that stage, you have executed your view and rendered your template.