On Wednesday 12 November 2003 05:04 pm, Warren Smith wrote:
> Jacob Hanson said:
> > It seems like dbPool ought to be able to trap an error like this
> > gracefully and seamlessly open new, replacement connections without
> > notice. At least that's what I would expect it to do. Maybe it still
> > needs a bit of work?
> I think it does. I needed a database connection pooling mechanism for a
> non-webware python project at work some time ago and, having seen dbPool
> discussions on this list, I decided to give it a look.
> The implementation is fairly simple and that is a good thing. However, I
> didn't like the fact that there was no provision whatsoever for dealing
> with connections that may not be good anymore and I also didn't like the
> way it "pre-allocated" the pool. I wanted something that would be able to
> grow on-demand up to some optional pre-defined limit.
> After a few attempts to hack dbPool to do what I wanted, I ended up
> writing my own pooling module. To solve the idle-timeout problem, I
> implemented a couple timestamp attributes in the class that wraps the
> connection and actually stored the wrapper in the pool instead of the
> underlying connection. One of the attributes gets set when the wrapper is
> instantiated and the other is set each time the __getattr__ method is
> called. The pool starts a thread when it is instatiated that periodically
> cycles through all of the connections in the pool and "expires" them based
> on either their age or idle-time.
> I'm still not completely happy with it, but it seems to work fine for my
> Unfortunately, the code belongs to my employer and I am not at liberty to
> share it without a lot of hassle that I frankly don't have time to deal
> with right now. I have wanted to rewrite it on my own time and try it out
> with webware, but as yet have not been able to.
> Perhaps someone can use my ideas and update dbPool or write a replacement.
I have been bothered by this posting of mine ever since I sent it, since it
seemed kind of lame. Consequently, I have MADE time this past week or so to
build an alternative to dbPool.
Here is the URL: http://www.wandrsmith.net/~warren/DbConnectionPool.py
I haven't had a change to test it with webware yet, but it seems to work in
the testing that I have done. It will run on Python 2.2, although the
testing code in the module relies on the logging module in 2.3.
Perhaps there is someone on this list who can give it a good test with
webware. I'm particularly interested in wether or not it solves the "wedged
thread" issue that some have had.
Both positive and negative feedback is welcome.