[mod_python] Reloading of modules

G . Sumner Hayes SumnerH at fool.com
Mon Jun 25 14:28:32 EST 2001


Adam Langley <agl at linuxpower.org> wrote:
> from mod_python import apache
> 
> i = 0
> def test(req):
>     req.content_type = "text/html"
>     req.send_http_header ()
> 
>     global i
>     req.write (str(i) + "<br>")
>     i += 1
[SNIP]
> This works as expected until you start refreshing quickly, when the
> counter gets reset.

Each Apache process has its own Python interpreter, and in a
default Apache install each process only handles 50 or 100
requests before exiting.  Which process you get for a particular
page load depends on the OS scheduler and the exact timing, but
on an unloaded machine you can easily hit the same one 10 or more
times in a row.

But in general, you can't keep server-side shared data this way.

  Sumner



More information about the Mod_python mailing list