problem with embedded python

Brandon Long blong at fiction.net
Mon Aug 20 19:08:37 EDT 2001


I'm using PyApache 4.22 with Apache 1.3.20.  I've looked at PyApache
4.25, and it doesn't appear to have any real changes except support for
Apache 2.x.  It is compiled against Python 2.1.

The usage case is that every apache request creates a new interpreter
with Py_NewInterpreter(), the code is run, and then the interpreter is
destroyed with Py_EndInterpreter().

The first request per Apache process works fine.  The second one failes
to import site because of exceptions during import os.

These exceptions are expected, but as near as I can tell, the exceptions
don't match anymore.  Ie, os.py as 'except AttributeError', but that
fails to catch the raised AttributeError.  When I change that line to
just 'except:', it catches the exception, and then fails later to catch
a NameError exception that it should.

I've used PyApache extensively with both python 1.5.1 and 1.5.2.  I
notice that now the exception module is actually a C module, and the
above behavior reminds me of trouble I've had with Python C modules
where something is initialized twice, and then the pointer matches don't
match.  I'm not familiar enough with how exceptions work in the
interpreter to figure this out, however.  Py_Initialize() looks like it
is only called once, and Py_Finalize() hasn't been called yet.

Any ideas?

Brandon
-- 
 "pretty code isn't always the right thing to do.  people spend much 
  more time reading mail than looking at the source code." 
   -- Michael Elkins, mutt author
                                           http://www.fiction.net/blong/




More information about the Python-list mailing list