def lock(self, dn, newdn): ''' This helper performs a simple atomic test and set lock using LDAP attributes. dn: the distinguished name of our mutex object newdn: new distinguished name object, e.g. "cn=newuid" ''' debug('Locking LDAP database...') for x in range(NUM_TRIES): try: self.ldap_wics.modrdn_s(dn, newdn) return except: print_exc(sys.exc_info()) time.sleep(SLEEP_DUR) raise ldap.TIMEOUT('Could not obtain lock on ' + dn)
def result(self,msgid=ldap.RES_ANY,all=1,timeout=-1): """ """ ldap_result = self._ldap_call(self._l.result,msgid,0,self._result_timeout) if not all: return ldap_result start_time = time.time() all_results = [] while all: while ldap_result[0] is None: if (timeout>=0) and (time.time()-start_time>timeout): self._ldap_call(self._l.abandon,msgid) raise ldap.TIMEOUT( "LDAP time limit (%d secs) exceeded." % (timeout) ) time.sleep(0.00001) ldap_result = self._ldap_call(self._l.result,msgid,0,self._result_timeout) if ldap_result[1] is None: break all_results.extend(ldap_result[1]) ldap_result = None,None return all_results
def _bind_fails3(self, who='', cred='', **kw): global _CALL_COUNTER _CALL_COUNTER += 1 raise ldap.TIMEOUT('Boo')