Warren Smith wrote:
> There is the dbpool module in Webware/Misc (?) that provides simple
> database pooling. There is also DbConnectionPool in the webware sandbox,
> which I wrote as a more fully featured alternative for dbpool.
> I have since pulled the basic pooling logic out into a separate module so
> that I could build pools of things besides database connections (FTP
> connections, FormKit forms, etc.). However, I haven't yet got around to
> refactoring DbConnectionPool to make it inherit from that generic pooling
> module. There are also some major changes that I would like to make to
> the pooling logic, such as pulling the expiration logic out into a
> separate method that could be called at check-in and check-out time, as
> well as by the expiration thread. I also would like to implement usage
> based expiration in addition to the idleness and age expiration that is
> already implemented.
If you want to tackle this problem properly, you may also want to allow
for thread affinity; i.e., a situation where resources are allocated on
a per-thread basis, and never shared or moved between threads. This is
what Zope does for its database connections, and it seems to be more
reliable than DBPool.
This would only really be an issue when you are dealing with C
extensions where threaded behavior is questionable, so that even moving
the exclusive use of the extension to different threads may cause a
problem. If it's Python resources, I think pooling should be sufficient.
Ian Bicking / ianb@... / http://blog.ianbicking.org