[python-ldap] Ldap connectors pool
Tarek Ziadé
ziade.tarek at gmail.com
Thu Sep 8 11:48:58 CEST 2011
Hey
I've been working on a pool class for ldap connectors, we're using for
the Firefox Sync server. It's a very simple class that provides a
context manager to create connectors, and offers features like:
- recycling existing connectors to avoid reconnections
- handles several connection binds
- retry a few times when the server is down or times out
- provides a max lifetime for connectors -- this is useful when you
have several ldap servers load balanced and you add a new one in the
pool: fresh connectors will use this new server **
It's been running in production for a few months now, except ** which
is to be introduced soon,
All those features are pretty generic and it seems to me that it would
be a good addition to the python-ldap project, since I haven't seen
such thing there when I started this.
If there's interest, I can isolate the pool, document it, and turn it
into a patch for Python-ldap
the code: https://hg.mozilla.org/services/server-core/file/tip/services/ldappool.py
Example of usage:
cm = ConnectionManager('ldap://localhost')
with cm.connection('bind', 'password') as conn:
... do something with conn...
Cheers
Tarek
--
Tarek Ziadé | http://ziade.org
More information about the python-ldap
mailing list