[mod_python] PYC download prompt (resolved)

Jim Gallacher jpg at jgassociates.ca
Fri Jan 20 19:21:40 EST 2006


Sean Jamieson wrote:
> Jim Gallacher wrote:
> 
>> Sean Jamieson wrote:
>>
>>> Jim Gallacher wrote:
>>>
>>>> Sean Jamieson wrote:
>>>>
>>>>> apache2/error.log is showing more than a few segfaults...
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Segfaults! Now we are getting somewhere. There are likely some 
>>>> subtle differences in the python libraries and apache modules being 
>>>> used on the server and laptop. The usual culprits libexpat and mysql 
>>>> clientlib used by php, but other libs can cause problems too. These 
>>>> links may help you sort it out:
>>>>
>>>> http://www.dscpl.com.au/articles/modpython-006.html
>>>> http://www.modpython.org/FAQ/faqw.py?req=all#2.13
>>>>
>>>> Jim
>>>
>>>
>>>
>>>
>>> I made the segfault stop, but I'm not sure why exactly...
>>> to start at the beginning, there was another weirdness going on with 
>>> mod_python, that was not a big deal, and I assumed to be "just how it 
>>> works":
>>> if my project is in a subdirectory under the document root, I'd have 
>>> to do my imports from the document root.
>>> i.e.
>>> DocumentRoot /var/www
>>> Project Root /var/www/project
>>> /var/www/project/index.py:
>>>    import project.package.module
>>> this seems strange as I sholud only have to do
>>>    import package.module
>>> with out having to include the directory that index.py actually 
>>> resides in...
>>> Now, keeping that in mind, I uploaded the source to my dev server, 
>>> and to stop the segfaults I simply changes the imports to the second 
>>> (expected) from, excluding the 'project' directory from the import path.
>>> *inhale*
>>>
>>> I don't know if that really fixed anything, or just caused some other 
>>> error to be happening that prevents the whatever code is segfaulting 
>>> from actually being run.
>>> But, in either case, I get no error or output or log messages telling 
>>> me useful. All I do get is:
>>> [notice] mod_python: (Re)importing module 'index' with path set to 
>>> '['/.....']'
>>> and once in a while this is above it:
>>> [notice] mod_python: (Re)importing module 'mod_python.publisher'
>>
>>
>>
>> Publisher has it's own import and reload mechanism. Using a python 
>> import statement for modules that may also be imported by 
>> mod_python.publisher may give interesting results. If your 
>> project.package.module does not contain functions that are published 
>> directly I would suggest moving it completely out of your DocumentRoot 
>> and put it somewhere on your python path, or use the apache PythonPath 
>> directive to add it to the path. eg.
>>
>>   PythonPath "['/home/sean/website-modules/',] + sys.path"
>>
>> This import issue is not likely related to the segfaults however.
>>
>>> OTOH, that link you gave me about PHP's mysql libs conflicting with 
>>> mod_python and MySQLdb might be the very thing causing problems, but 
>>> BOTH my laptop and my dev server have php4.4.0 installed... and both 
>>> are from ubuntu's apt (infact, I haven't custom compiled anything on 
>>> either machine since I built them, all are package managed, and 
>>> recently updated)
>>
>>
>>
>> A few weeks ago I ran apt-get update for python related packages on 
>> one of my debian machines and immediately started getting apache 
>> segfaults. Turned out that php4-mysql was using libmysqlclient.so.10 
>> and the new python was using libmysqlclient.so.12. Updating php4-mysql 
>> brought the 2 libs in line and the segfault went away. I don't think 
>> this sort of problem is easily solved by any package manager, so it's 
>> something to keep in mind when doing updates.
>>
>> Jim
>>
>> PS. It's a good idea to keep discussions on list.
> 
> 
> OK, so after many hours of hair pulling, I finally figured out the 
> problem *is* with PHP's mysql library.
> 
> Disabling PHP entirely allowed my python code, which uses MySQLdb, to work.
> 
> Tomorrow I'm going to figure out how to make PHP and MySQLdb play 
> nicely, taking your comment above into consideration.

FYI, here's a starting point:

$ ldd /usr/lib/python2.4/site-packages/_mysql.so |grep mysql
$ ldd /usr/lib/php4/20050606/mysql.so |grep mysql

(The php mysql.so file may be in a different location on Ubuntu).

Jim



More information about the Mod_python mailing list