[mod_python] 2006 "MySQL server has gone away" failures

Fred of UrlBit.Us fred at urlbit.us
Fri Jan 12 17:42:25 EST 2007

On Friday 12 January 2007 12:31, Jorey Bump uttered thusly:
> Martijn Moeling wrote:
> > Now the connections get closed nicely and mysql does not run out of
> > resources anymore.
> Interesting solution, but aren't you now (briefly) opening a database
> connection for every page view, regardless of it actually needing one?

In my particular application most pages are hitting the database, so that's 
not really a problem.

> Also, it looks like the OP is using the PSP handler, not a custom one.

Actually, in my case I am calling the PSP class directly rather than using 
the Apache directives to do it. Most of the code will be in libraries and 
just a touch will actually be in PSP.

> In that case, the best solution might be to explicitly open and close
> the db handle before and after every query (or tightly grouped series of
> queries). Recent versions of MySQLdb have made it difficult to create
> persistent db connections, and users are advised against it, since the
> overhead of creating new connections is negligible. I had to rewrite a
> number of applications that imported a shared db handle, due to this
> change. Bummer. :(

Curious. This highlights some questions I have about what exactly mod_python 
is doing. Does mod_python behaves well with MPM? I would rather use MPM over 
the perforking I currently do (to mainly keep legacy PHP happy). Basically, 
what are the issues with regards the Global Interpreter Lock and MPM? And 
are there any other issues I need be concerned about with regards to states 
and sessions and loaded modules?

-- Fred
Bite those long URLs!

More information about the Mod_python mailing list