From: Alain S. <asp...@gm...> - 2007-03-20 17:28:39
|
You are working asynchronously ! add a ldap.result() into your try: except or use the synchronous ldap.search_s() method and you will get your error in the expected order. I you want to survive to ldap restart, use the ReconnectLDAPObject that do the job nicely. BUT this let a good QUESTION : If I start 10 asynchronous ldap requests when the server is down, how many exception will I get ? 1 or 10 ? easy to test :-) On 3/20/07, Anil Jangity <an...@en...> wrote: > > If I restart the LDAP server, while connected to it using python-ldap, > it doesn't seem to be throwing an exception at the right time. > > self.logger('*** about to do a search ***') > result = g.ldap[customer][uid].search(base=suffix, scope="base", > attr=["dn"]) > self.logger('*** finished search ***') > > g.ldap is a wrapper method that just does this: > try: > self.logger('1') > ldap_result_id = self.l.search(ldap_url.dn, ldap_url.scope, > ldap_url.filterstr, ldap_url.attrs) > self.logger('2') > except ldap.LDAPError, e: > self.logger("LDAP SEARCH failed: %s" % (e)) > return False > > Once connected to the ldap server, I do stop-start ldap server. Then, > I do two searches in order. The 2nd search throws an exception "Can't > contact LDAP server". I am just wondering why it doesn't do it the > first time? > > Mar 20 09:43:35 DEBUG 127.0.0.1 *** about to do a search *** > Mar 20 09:43:35 INFO LDAP SEARCH: dn: uid=demo, ou=People, o=entic.net > scope: 0 filter: (objectClass=top) > Mar 20 09:43:35 INFO 1 > Mar 20 09:43:35 INFO 2 > Mar 20 09:43:36 DEBUG 127.0.0.1 *** about to do a search *** > Mar 20 09:43:36 INFO LDAP SEARCH: dn: uid=demo, ou=People, o=entic.net > scope: 0 filter: (objectClass=top) > Mar 20 09:43:36 INFO 1 > Mar 20 09:43:36 INFO LDAP SEARCH failed: {'info': '', 'desc': "Can't > contact LDAP server"} > Mar 20 09:43:36 DEBUG 127.0.0.1 *** finished search *** > > ------------------------------------------------------------------------- > Take Surveys. Earn Cash. Influence the Future of IT > Join SourceForge.net's Techsay panel and you'll get the chance to share > your > opinions on IT & business topics through brief surveys-and earn cash > http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV > _______________________________________________ > Python-LDAP-dev mailing list > Pyt...@li... > https://lists.sourceforge.net/lists/listinfo/python-ldap-dev > -- -- Alain Spineux aspineux gmail com May the sources be with you |