Graham Dumpleton
grahamd at dscpl.com.au
Sun Jul 10 07:43:38 EDT 2005
You misunderstand how Apache/mod_python works. If Apache is running in prefork mode each unique request is not necessarily managed within the same process. As a result, setting a global variable doesn't mean the next request will see the same value as it could be executing in a different process. More than likely, your Apache 2 configuration was set to run in worker mode. That is, all requests were handled in the same process but possibly as different threads. Thus it always saw the updated value. Not so with prefork mode though. Since you don't have access to sessions in mod_python 2.7, you are going to have to come up with your own way of saving state out to the file system somehow to track such things. Graham On 10/07/2005, at 9:28 PM, antoine wrote: > Hello, > > I've this problem trying to get a particular var to be loaded once and > for all using mod_python 2.7 on apache 1.3 (debian sarge stable) with > python 2.1. The same code worked perfectly well with mod_python > 3.1/apache2/python2.3 but I've been a little bit too optimistic on my > hosting server uptodateness and spent the last week with downgrading > issues... > > So I'm using the publisher handler and here is a resume of my index.py: > > bigdic = None > > def index(req): > global bigdic > if bigdic: > req.write("bigdic already loaded") > else > req.write("bigdic loading...") > bigdic = loooong_and_painfull_process() > req.write("done, pfiouh") > > this work perfectly well with the new components (apache2 and all) but > not with the old one (apache1.3 and company) which I _have to_ use, > meaning I get the "bigdic loading....done" message every time I reload > the page. > > I tried the PythonImport but it segfaults apache (wether at the > virtual host level or the directory level) > > I'm not running out of idea yet but before I get into crazy mode > looking for a complicated solution has any of you encounter and > resolved the same problem before? > > Just to make it clear : upgrading any of the component is not an > option, I could rewrite/patch the publisher handler though. > > Thanks for your time > -- > Antoine > http://delaunay.org/antoine > > _______________________________________________ > Mod_python mailing list > Mod_python at modpython.org > http://mailman.modpython.org/mailman/listinfo/mod_python
|