john spurling
synec at viscous.org
Wed Aug 27 21:07:18 EST 2003
On Wed, Aug 27, 2003 at 10:51:32PM -0500, Simon Willison wrote: > I'm experimenting with the idea that mod_python stays resident in > memory. Here's the handler script I'm using: > > from mod_python import apache > > counter = 0 > > def handler(req): > req.content_type = 'text/html' > req.send_http_header() > global counter > counter = counter + 1 > req.write("Counter: %d" % counter) > return apache.OK > > If I load it up in a browser and continuously hit refresh, the number > only increments every 4 or 5 page loads. I was expecting it to increment > each time. Don't worry - this isn't how I intend to implement a page > counter, it's just an experiment I'm using to try and gain a better > understanding of this capability. grep for "StartServers" in your httpd.conf. i'm guessing it's about 4 or 5. i had this same problem when implementing sessions. each httpd instance has its own individual python interpreter. you might just want to set StartServers to 1 while playing around, but then don't forget to increase it before "shipping" any code so you don't inadvertantly write a bug like you have in the above example code. it's easy to do. cheers, john -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: not available Url : http://mailman.modpython.org/pipermail/mod_python/attachments/20030827/f318d6e2/attachment-0003.bin
|