does python have a generic object pool like commons-pool in Java

Rick Lawson lawson89 at gmail.com
Wed Jul 15 08:09:54 EDT 2009


On Jul 15, 4:53 am, Jonathan Gardner <jgard... at jonathangardner.net>
wrote:
> On Jul 14, 6:34 pm, Rick Lawson <lawso... at gmail.com> wrote:
>
> > Appreciate any help on this. I am porting an app from Java to python
> > and need generic object pooling with hooks for object initialization /
> > cleanup and be able to specify an object timeout.
>
> Are you looking for something like a thread pool or a connection pool?
> Such a thing is easy to code in Python. Might as well write one from
> scratch for your particular need.
>
> By the way, a tip for writing Python: Forget Java. If you're porting
> an app, consider rewriting it from the architecture on up. You'll save
> yourself time and get a better result.

Jonathan,

Thanks for the advice but would like to pick your brain a little more.
The pool I need is not a thread pool or db pool. I need to pool
objects which are a proxy for an external C process that communicates
via sockets. The pool is necessary because the initial connection/
authentication is expensive, plus the connection needs to be recycled
every so often due to instability on the C side. The existing Java
code uses commons-pool which incidentally is the base object pool for
a db connection pooling library (DBCP). Anyway, maybe this is just so
easy to do in Python that everyone rolls their own - but I have done a
lot of googling with no luck.

I just hate to re-invent the wheel here - I guess I should look at a
db connection pooling library and see if they have a generic object
pool somewhere in there. Any you can recommend that are more or less
standalone db connection pool libraries ?

Thanks,
Rick



More information about the Python-list mailing list