[mod_python] Re: python exceptions cause Apache to crash

Graham Dumpleton graham.dumpleton at gmail.com
Mon Aug 4 21:44:20 EDT 2008


Please use reply-all and keep discussion on the list, don't reply just to me.

Have you tried uninstalling all versions of Python and mod_python
first and then install it? Ie., don't install when you have existing
versions on the system.

When installing packages, are you doing it as a user with
administrator privileges?

Graham

2008/8/5  <ynj0qeh02 at sneakemail.com>:
> Unfortunately, when I tried to install the mod_python 3.3.1 for 2.5 I got
> this traceback:
> Traceback (most recent call last):
>   File "boot_com_servers.py", line 21, in <module>
>   File "C:\Python25\Lib\site-packages\pythoncom.py", line 3, in <module>
>     pywintypes.__import_pywin32_system_module__("pythoncom", globals())
>   File "C:\Python25\Lib\site-packages\win32\Lib\pywintypes.py", line 98, in
> __import_pywin32_system_module__
>     ('.dll', 'rb', imp.C_EXTENSION))
> ImportError: DLL load failed: The specified procedure could not be found.
>
> and when I try to start apache 2 anyway, it says "The requested operation
> has failed!"
>
> That's why I was using the version for 2.4.
>
> On Mon, Aug 4, 2008 at 9:21 PM, Graham Dumpleton
> graham.dumpleton-at-......... |public mailing list| <...> wrote:
>>
>> 2008/8/5  <ynj0qeh02 at sneakemail.com>:
>> > Thanks for the quick reply!  Answers inline...
>> >
>> > On Mon, Aug 4, 2008 at 7:28 PM, Graham Dumpleton
>> > graham.dumpleton-at-......... |public mailing list| <...> wrote:
>> >>
>> >> What operating system? What version of Python? What version of
>> >> mod_python?
>> >
>> > I am on Windows XP SP3 using Python 2.5 in mod_python 3.3.1
>> >
>> > I hacked the binary to use 2.5 on Windows, but the same problem is
>> > reproducible on Ubuntu 7.10 using the latest source from svn compiled
>> > with
>> > python 2.5.
>> >
>> >> What startup messages for mod_python are in the Apache error log?
>> >
>> >
>> > [Mon Aug 04 20:03:21 2008] [notice] Server built: Nov  7 2007 11:48:48
>> > [Mon Aug 04 20:03:21 2008] [notice] Parent: Created child process 27164
>> > [Mon Aug 04 20:03:22 2008] [error] python_init: Python version mismatch,
>> > expected '2.4.3', found '2.5'.
>>
>> This is why it is probably breaking. Install mod_python compiled
>> against Python 2.5. The version you are using was compiled against
>> older version of Python.
>>
>> Fix your installation and try again.
>>
>> Do you get similar warnings on your other platform as well?
>>
>> Graham
>>
>> > [Mon Aug 04 20:03:22 2008] [error] python_init: Python executable found
>> > 'C:\\xampp\\apache\\bin\\apache.exe'.
>> > [Mon Aug 04 20:03:22 2008] [error] python_init: Python path being used
>> > 'C:\\Program
>> >
>> > Files\\OpenLibraries\\python;C:\\WINDOWS\\system32\\python25.zip;C:\\Python25\\Lib;C:\\Python25\\DLLs;C:\\Python25\\Lib\\lib-tk;;C:\\xampp\\apache\\bin'.
>> > [Mon Aug 04 20:03:22 2008] [notice] mod_python: Creating 8 session
>> > mutexes
>> > based on 0 max processes and 250 max threads.
>> >
>> >>
>> >>
>> >> What is the mod_python configuration you have in Apache configuration
>> >> files?
>> >
>> >
>> > PythonOption mod_python.mutex_directory "/pytmp"
>> > PythonOption mod_python.mutex_locks 8
>> >
>> > AliasMatch      ^/slique(.*)        'C:/Documents and Settings/Jason/My
>> > Documents/Coding/eclipse-workspace/slique-dev/src/$1'
>> >
>> > <Directory 'C:/Documents and Settings/Jason/My
>> > Documents/Coding/eclipse-workspace/slique-dev/src'>
>> >     Options Indexes ExecCGI FollowSymLinks MultiViews
>> >     AllowOverride All
>> >
>> >     AddHandler mod_python .py
>> >     PythonHandler mod_python.publisher
>> >     PythonDebug On
>> >     PythonPath "sys.path + ['C:/Documents and Settings/Jason/My
>> > Documents/Coding/eclipse-workspace/slique-dev/src']"
>> >
>> > </Directory>
>> >
>> >>
>> >>
>> >> Specifically, are you setting PythonPath directive in really strange
>> >> ways?
>> >
>> > PythonPath is set this way
>> > PythonPath "sys.path + ['C:/Documents and Settings/Jason/My
>> > Documents/Coding/eclipse-workspace/slique-dev/src']"
>> >
>> >>
>> >>
>> >> Does it happen if you don't use the 'logging' module?
>> >
>> > If I comment out logging.exception('I crash'), then the traceback prints
>> > to
>> > screen as expected.
>> >
>> >>
>> >> Graham
>> >>
>> >> 2008/8/5 Jason Carver <ynj0qeh02 at sneakemail.com>:
>> >> > Here is code that consistently crashes Apache for me:
>> >> >
>> >> > import logging
>> >> >
>> >> > def index(req):
>> >> >     """Handles all Browser Requests"""
>> >> >     try:
>> >> >         reqHandler = logging.StreamHandler(req)
>> >> >         logging.getLogger('').addHandler(reqHandler)
>> >> >         if req.form.has_key('action'):
>> >> >             raise Exception('Goodbye Apache')
>> >> >     except Exception, e:
>> >> >         logging.exception('I crash')
>> >> >         raise
>> >> >
>> >> > Now just go to the site with /?action=dosomething and it will crash
>> >> >
>> >> > Removing the if statement, the exception, or the logger are all ways
>> >> > of
>> >> > alleviating the crash, but none of them should be necessary.
>> >> >
>> >> > Cheers,
>> >> > Jason
>> >> >
>> >> > On Mon, Aug 4, 2008 at 2:51 PM, Jason Carver
>> >> > <ynj0qeh02 at sneakemail.com>
>> >> > wrote:
>> >> >>
>> >> >> Hi all,
>> >> >>
>> >> >> I am having the craziest error, confirmed on both a LAMPython and
>> >> >> WAMPython setup: exceptions in mod_python are causing Apache to
>> >> >> crash
>> >> >> hard.
>> >> >> Even stranger is that the exceptions have to meet a few specific
>> >> >> conditions
>> >> >> to cause Apache to crash.
>> >> >>
>> >> >> As best I can tell those conditions include:
>> >> >>
>> >> >> raising an exception (this problem always goes away if the exception
>> >> >> is
>> >> >> commented out)
>> >> >> having the exception be inside an if-block that tests a dictionary
>> >> >> (the
>> >> >> problem goes away if I do something like """if 'hello' == 'hello':
>> >> >> raise
>> >> >> Exception('goodbye')""")
>> >> >> catching the exception and logging it using the python built-in
>> >> >> logging.exception(e) (the problem goes away if I comment out the
>> >> >> logger)
>> >> >>
>> >> >> Apache does not write anything to its error.log, so it was a bit of
>> >> >> an
>> >> >> adventure to discover all these elements.
>> >> >>
>> >> >> Any ideas?
>> >> >>
>> >> >> Cheers,
>> >> >> Jason
>> >> >
>> >> > _______________________________________________
>> >> > Mod_python mailing list
>> >> > Mod_python at modpython.org
>> >> > http://mailman.modpython.org/mailman/listinfo/mod_python
>> >> >
>> >> >
>> >
>> >
>
>


More information about the Mod_python mailing list