The pattern seems to be to attach things to the registry:

# setup
config.registry.ldap_pool = LdapPool()

# in a view
conn = request.registry.ldap_pool.get_connection()
conn.unbind()

Make sure there's a way to notify the pool when a connection is closed. The
pool obviously needs to be thread-safe.


On Thu, Dec 29, 2011 at 12:58 PM, Stephan Ellis <[email protected]>wrote:

> I am closing the connections right after using them, via the unbind()
> method, which according to the docs for python-ldap disconnects from the
> directory server.  I could use a request callback to unbind, but where
> should I put the connection object when the request starts up?  Also, I
> don't need the connection object for every request.  I guess what I'm
> really asking is this: If I have a connection I want to use from multiple
> threads (and i'm not worried about blocking while request threads are
> waiting for the connection object to free up), where should that instance
> live?
>
> Thanks!
> -stephan
>
>
> On Thu, Dec 29, 2011 at 10:31 AM, Michael Merickel <[email protected]>wrote:
>
>> It sounds like you just aren't closing the connections when you're done
>> with them. The request callbacks provide a way to deal with this if you
>> can't just immediately close the connection.
>>
>>  On Thu, Dec 29, 2011 at 10:29 AM, Stephan Ellis <[email protected]
>> > wrote:
>>
>>>  Hello All,
>>>
>>>   I'm looking for some guidance.  I wrote a small app that uses
>>> python-ldap to query and modify a Directory (MS Active Directory).  The
>>> problem I'm having is that occasionally the AD server stops accepting new
>>> connections and netstat shows a ton of connections to the directory
>>> server.  What I'm wondering is, what is the best way to create a connection
>>> or pool of connections and then have each request reuse that connection.
>>>
>>> I also found this:
>>>
>>> http://pypi.python.org/pypi/ldappool/
>>>
>>> which looks like it can handle the pool of connections for me, but I'm
>>> not sure where I should create the pool in my app so that the views can
>>> exploit it.
>>>
>>> Thanks in advance!
>>>
>>>
>>> -stephan
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "pylons-discuss" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/pylons-discuss?hl=en.
>>>
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "pylons-discuss" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/pylons-discuss?hl=en.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "pylons-discuss" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/pylons-discuss?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to