Graham Dumpleton
graham.dumpleton at gmail.com
Mon Mar 19 15:57:02 EST 2007
On 20/03/07, Nicholas Milkovits <nmilkovits at gmail.com> wrote: > Hello all, > > I have a quick question about how apache2 and mod python work. When > apache (running in prefork mode) decides to scale back the number of > running child processes running because of a low request volume, does > mod python ensure that all objects have their __del__ methods called No it doesn't currently ensure that __del__ methods are called. > or does apache just kill it and release the memory back to the system? Yes and no. See below. > I am running across a problem where my oracle db has to many sessions > open (although they are marked as idle/invalid) and it appears to be > because the client application is never explicity telling oracle to > close the sessions before exiting. Is there any way to ensure a chunk > of code gets run before apache kills the process? When an Apache child process is killed the socket will be closed off. The Oracle server side should detect this and recycle the connection automatically. Because of this fact, I would suggest the problem might lie elsewhere. That said, look at the apache.register_cleanup() method. http://www.modpython.org/live/current/doc-html/pyapi-apmeth.html This allows registration of callback to be called when Apache child process is being shutdown. Note though that it is not guaranteed that the callback will be called as various things could cause shutdown to hang and parent Apache process will forcibly kill off child processes if this occurs. Child process could also just die of their own accord as well which would also mean that this would not be triggered. Graham
|