[mod_python] How to perform cleanup action when the python process dies?

Nick nick at dd.revealed.net
Sun Jun 12 00:57:20 EDT 2005


When you restart apache you are actually destroying the python 
interpreter, so I wouldn't worry about ANYTHING being left behind on a 
restart.

Nick

Dan Eloff wrote:
> I have global resources that persist as long as the process does
> (database connections) but they could also be files or sockets or
> other resources that need to be released. Python destructors are very
> dicey from what I've heard, there seems no guarantee that the __del__
> method on the connection pool will be called before the database
> module is itself destroyed. I can't use req.register_cleanup() since
> the objects stay alive across all the requests. When apache is
> restarted though, how do I ensure the database connections were closed
> on exit?
> 
> I saw a similar post to this on the list, but it just recommends not
> to trust python destructors for important things like closing a
> database connection.



More information about the Mod_python mailing list