Chuck Esterbrook wrote: >On Friday 03 May 2002 06:55 am, Costas Malamas wrote: > >>Well, I am convinced, I'll go ahead and try it out. >> >>What I am not following from the docs though is how do you use >>DBPool; I am not familiar with threading (at all!), so I don't get >>the setup. E.g. do you call DBPool once in your application (somehow >>have a central DBPool that you get connections from) or do can you >>call it whenever you need a connection and it will "know" which >>connection to give back? I am guessing the former --in which case, >>where in WK is the best place to put it? subclass Application? >> > >Every time you think of subclassing Application just to store >application wide resources, you could just as easily (or more easily) >get along with a module for this purpose and put the objects in module >level variables. > >This might also lead to further uses of that module in other settings. > >Surprisingly, there is not yet a Wiki page on this that I see. > >Looking back at the MiddleKit code that uses the DBPool, it simply gets >a connection like this: > conn = self._pool.getConnection() > >So as you guessed, you ask the pool for a connection whenever you need >one. When you lose the reference to the connection, it will go back in >the pool for other threads to use. > >Maybe the doc string needs further improvement. > > >-Chuck >
The one thing that I never figured out was how to use DBPool in a fasion that actually allowed the pool to exits once and keep the pool of connections. This was my motication to write my own pooling mechanism. I see now that you store is as an instance variable somewhere in a module that gets used in the application. This was not obvious. It would be more obvious if the DBPool used it's own class variables or module variables to store the pool eg. ConnectionPool stores the pool in a class variable with locks around the pool creation. All instances of ConnectionPool in my case share the same physical pool of connections. --Karl _______________________________________________________________ Have big pipes? SourceForge.net is looking for download mirrors. We supply the hardware. You get the recognition. Email Us: [EMAIL PROTECTED] _______________________________________________ Webware-discuss mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/webware-discuss