From: Rimon B. <ba...@cs...> - 2003-07-08 16:58:16
|
Hi Anthony, This is normal behaviour. I'll explain what's going on... Your single Apache server actually has a number of children that take turns at processing requests. These children are either threads or processes, depending on your configuration. In any case, you may have multiple copies of mod_python, one in each of the children. If this is the case, you will have multiple spyce engines running too, and each will have it's own pool object. On top of this, Apache cycles its children after they have processed a certain number of requests, to help with stability, possible memory leaks, etc. However, all this should not matter to you, unless you need to share or keep information in each of the children. And, unless you have sever performance reasons to do otherwise, you should try to avoid this: i.e. you should keep the Apache children stateless. If you need to share information between children, you could possibly use one of the shared memory Python modules, or some other mechanism. This is probably overkill... The way you should write your code is to check for some variable in the pool. It's there, use it. If not, generate a new one and use it. After processing a few requests you'll see that each of the children will have processed its first request and you will be using cached connections from that point onwards, whichever child happens to be processing your request. If you don't like this idea of having multiple connections, you can reduce your level of concurrency within Apache directly. Or, you can proxy to the spyce webserver or interface to the Spyce engine via FastCGI, which both implement concurrency as individual threads within the *same* Python interpretter. I hope that helps. All the best, Rimon. On Thu, 3 Jul 2003, anthony fernandez wrote: >I am running Spyce with Apace 2.0.40, mod_python and python2.2. >Also I am using MySQLdb module for python2.2. > >I am trying to keep a persistent MySQL connection in a 'pool' server object. > >The problem is when I access the 'pool' from another page it does not give >me consistent connection. > >Sometimes after I reload the page, the 'pool' returns null and sometimes >the connection is there. > >So the tables that I query, sometimes show and sometimes don't. > >It is really annoying. > >Anyone know the answer to this? > >Thanks > |