Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can WSGI middleware run code after a response is returned?

I understand that WSGI Middleware's purpose is to extend functionality between a request and a response.

But can some of this code be run after the response is returned?

I need to store a request/response log in an external database, and wouldn't want this to slow the response times down.

Thanks! :)

like image 740
RadiantHex Avatar asked May 27 '26 10:05

RadiantHex


1 Answers

Did you consider spawning a new thread or using a queue manager?

This way you can return the view and process the data in the background.

This answer here has more information:

How to fork a process in python/django?

like image 158
Konstantin Schubert Avatar answered Jun 04 '26 23:06

Konstantin Schubert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!