[mod_python] Re: python exceptions cause Apache to crash

Jason Carver ynj0qeh02 at sneakemail.com
Mon Aug 4 16:55:26 EDT 2008

Here is code that consistently crashes Apache for me:

import logging

def index(req):
    """Handles all Browser Requests"""
        reqHandler = logging.StreamHandler(req)
        if req.form.has_key('action'):
            raise Exception('Goodbye Apache')
    except Exception, e:
        logging.exception('I crash')

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.


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20080804/0f8fc167/attachment.html

More information about the Mod_python mailing list