[mod_python] Re: python exceptions cause Apache to crash

Graham Dumpleton graham.dumpleton at gmail.com
Mon Aug 4 19:28:08 EDT 2008


What operating system? What version of Python? What version of mod_python?

What startup messages for mod_python are in the Apache error log?

What is the mod_python configuration you have in Apache configuration files?

Specifically, are you setting PythonPath directive in really strange ways?

Does it happen if you don't use the 'logging' module?

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