Ron Teitelbaum wrote:
While polling it appears that we have to call result for every record that is waiting to be read. Since we added a 250 millisecond delay between calls larger queries are taking a really long time.
Why do you wait such a long time in an extra time.sleep() call?
result = self.connection.result(id, True, 0)
time.sleep(0.25)
Hmm, I don't know very much of the inner workings of OpenLDAP's function ldap_result(). The behaviour also may depend on the version of OpenLDAP.
But how about fiddling around a little bit with the timeout argument for result()? You're blocking your while-loop with time.sleep() anyway. And the C wrapper module releases Python's GIL.
Something like
[..within while loop..]
try:
result = l.result(msgid,True,0.25)
except ldap.TIMEOUT:
continue
else:
# Process result
[..within while loop..]
I played around a little bit with the script attached on a local server
with more than 1000 entries.
BTW: If you're after correctly dispatching results to several outstanding search requests you should probably use method result2() which also returns the message ID of the originating request:
http://python-ldap.sourceforge.net/doc/html/ldap.html#ldap.LDAPObject.result2Use result3() if LDAPv3 extended controls are to be used to also receive controls sent by the server.
Ciao, Michael.
async_result.py
Description: application/python
------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________ Python-LDAP-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/python-ldap-dev
