[mod_python] mod_python + MySQLdb + Apache strange behavoir

Earle Ady earle.ady at gmail.com
Thu Sep 15 01:06:51 EDT 2005


I managed to self-diagnose and repair this problem.  However, I  
turned up another one, although unrelated.

As for the MySQLdb inconsistencies, varying error messages, etc.  The  
problem was actually quite simple!  I was using  
MySQLdb.cursors.DictCursor as a cursor type and only importing MySQLdb.

I added a simple import for MySQLdb.cursors, and all of my problems  
went away.   This is something I never would have guessed from the  
behavioir and errors of mod_python and MySQLdb linkage, but a lot of  
persistence and a truckload of tenacity managed to dig it up.

It's bizarre that it would work at all, given the fix.   If anyone  
else is having these problems, double check to see what type of  
cursor they are using in MySQLdb, and if they are doing the import  
specifically.  It should have been more clear as using the standard  
cursor never had a problem but I obviously overlooked this for awhile.

On a side note, my exact same setup on a Linux machine, when moved to  
an OSX machine (same versions of everything...), craps out when  
trying to use Sessions when acquiring a mutex lock.  Is this a known  


On Sep 9, 2005, at 4:38 AM, Graham Dumpleton wrote:

> On 09/09/2005, at 3:26 PM, Earle Ady wrote:
>> I seem to be having some strange behavior between mod_python and  
>> MySQLdb under Apache.
>> I have relatively simple .PSP's that will work one second, and  
>> then fail on a reload.  Sometimes they work, sometimes they  
>> don't.  To make things even more bizarre, if I utilize the same  
>> logic in another .PSP it may work!  I can't seem to narrow down  
>> what this problem is.
>> I read an article from two years ago about conflicts between PHP  
>> running parallel to mod_python.  I have deactivated the PHP module  
>> loading within Apache, and the
>> problem still persists.
>> Error messages vary, nothing seems to fix things properly.
>> Has anyone else had these sorts of problems?
> There are known problems, but without the error messages from the  
> Apache
> error log file, we would be guessing.
> Does the problem occur in PSP code independent of use of MySQLDB?  
> Are you
> mixing use of mod_python.psp and mod_python.publisher and thus are  
> using
> "from mod_python import psp" or "import mod_python.psp" explicitly?
> You might try latest beta of mod_python 3.2 as some issues related to
> module importing when using mod_python.publisher and mod_python.psp
> together are addressed.
> Graham

More information about the Mod_python mailing list