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