Skip to content

Commit

Permalink
Explicitly list limit exception types
Browse files Browse the repository at this point in the history
  • Loading branch information
stroeder committed Oct 24, 2015
1 parent b8844cb commit 5d85c44
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
8 changes: 5 additions & 3 deletions Demo/pyasn1/noopsearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@

from ldap.controls.openldap import SearchNoOpControl

LDAPLimitErrors = (ldap.TIMEOUT,ldap.TIMELIMIT_EXCEEDED,ldap.SIZELIMIT_EXCEEDED,ldap.ADMINLIMIT_EXCEEDED)

SEARCH_TIMEOUT=30.0

try:
Expand Down Expand Up @@ -56,7 +54,11 @@
serverctrls=[SearchNoOpControl(criticality=True)],
)
_,_,_,search_response_ctrls = ldap_conn.result3(msg_id,all=1,timeout=SEARCH_TIMEOUT)
except LDAPLimitErrors,e:
except (
ldap.TIMEOUT,
ldap.TIMELIMIT_EXCEEDED,
ldap.SIZELIMIT_EXCEEDED,
ldap.ADMINLIMIT_EXCEEDED),e:
ldap_conn.abandon(msg_id)
sys.exit(1)

Expand Down
9 changes: 7 additions & 2 deletions Lib/ldap/controls/openldap.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
See http://www.python-ldap.org/ for project details.
$Id: openldap.py,v 1.4 2015/09/18 17:24:39 stroeder Exp $
$Id: openldap.py,v 1.5 2015/10/24 16:21:14 stroeder Exp $
"""

import ldap.controls
Expand Down Expand Up @@ -63,7 +63,12 @@ def noop_search_st(self,base,scope=ldap.SCOPE_SUBTREE,filterstr='(objectClass=*)
serverctrls=[SearchNoOpControl(criticality=True)],
)
_,_,_,search_response_ctrls = self.result3(msg_id,all=1,timeout=timeout)
except LDAPLimitErrors,e:
except (
ldap.TIMEOUT,
ldap.TIMELIMIT_EXCEEDED,
ldap.SIZELIMIT_EXCEEDED,
ldap.ADMINLIMIT_EXCEEDED
),e:
self.abandon(msg_id)
raise e
else:
Expand Down

0 comments on commit 5d85c44

Please sign in to comment.