Question

Example code for the repoze.bfg web framework performs post-response cleanup by adding a __del__ method to an object attached to the request's environ.

Is there a better way to clean up database connections, etc. after the response has been completely sent to the client?

Was it helpful?

Solution

Since you are dealing with repoze.bfg, best you use their documented way of doing things as it is going to be compatible with their framework and how they manage the request lifecycle. That said, if you want the generic WSGI way of doing it, it is documented in:

http://code.google.com/p/modwsgi/wiki/RegisteringCleanupCode

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top