[python-ldap] ldap.init_fd() patch for python-ldap-2.4.15
Michael Ströder
michael at stroeder.com
Fri Sep 12 14:08:48 CEST 2014
Mark R Bannister wrote:
> On 10/09/2014 13:43, Michael Ströder wrote:
>> Mark R Bannister wrote:
>>> I needed ldap.init_fd(), so I wrote a patch. Please find attached. Hope this
>>> works for you too. I've only tested on OpenSuSE.
>> Could you please elaborate on why you need that?
>
> Yes of course. I have a multi-threaded server that maintains a pool of worker
> threads. Each thread can manage multiple client requests, and each client
> request may be processing a different LDAP connection. The main worker loop
> needs to select() on a list of file descriptors to see if there is any pending
> I/O to process. This might be new incoming sockets, new commands received from
> existing clients, or new data received from an asynchronous LDAP operation.
>
> I therefore need ldap.init_fd() so that I have a file descriptor that I can
> pass to select().
I'm a bit concerned about new LDAPObject classes not fitting into normal class
hierarchy.
Therefore I've added support to CVS HEAD for getting the file descriptor of an
existing connection via LDAPObject.get_option(ldap.OPT_DESC). Could you please
test whether that would also be a viable solution for use-case?
In fact I thought many times whether LDAPObject class should open connection
itself, especially to get more control with error handling (various TLS
errors/checks etc.). So instead of passing in the fd the LDAPObject class
itself would use socket module and use _ldap.init_fd().
But I'm not sure whether I overlook all implications by such an approach for
existing code.
Ciao, Michael.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2398 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://mail.python.org/pipermail/python-ldap/attachments/20140912/96299977/attachment.bin>
More information about the python-ldap
mailing list