@@ -820,8 +820,7 @@ def get_naming_contexts(self):
820
820
class ReconnectLDAPObject (SimpleLDAPObject ):
821
821
"""
822
822
:py:class:`SimpleLDAPObject` subclass whose synchronous request methods
823
- automatically reconnect and re-try in case of server failure
824
- (:exc:`ldap.SERVER_DOWN`).
823
+ automatically reconnect and re-try in case of server failure.
825
824
826
825
The first arguments are same as for the :py:func:`~ldap.initialize()`
827
826
function.
@@ -833,6 +832,10 @@ class ReconnectLDAPObject(SimpleLDAPObject):
833
832
* retry_delay: specifies the time in seconds between reconnect attempts.
834
833
835
834
This class also implements the pickle protocol.
835
+
836
+ .. versionadded:: 3.5
837
+ The exceptions :py:exc:`ldap.SERVER_DOWN`, :py:exc:`ldap.UNAVAILABLE`, :py:exc:`ldap.CONNECT_ERROR` and
838
+ :py:exc:`ldap.TIMEOUT` (configurable via :py:attr:`_reconnect_exceptions`) now trigger a reconnect.
836
839
"""
837
840
838
841
__transient_attrs__ = {
@@ -842,6 +845,7 @@ class ReconnectLDAPObject(SimpleLDAPObject):
842
845
'_reconnect_lock' ,
843
846
'_last_bind' ,
844
847
}
848
+ _reconnect_exceptions = (ldap .SERVER_DOWN , ldap .UNAVAILABLE , ldap .CONNECT_ERROR , ldap .TIMEOUT )
845
849
846
850
def __init__ (
847
851
self ,uri ,
@@ -970,7 +974,7 @@ def _apply_method_s(self,func,*args,**kwargs):
970
974
self .reconnect (self ._uri ,retry_max = self ._retry_max ,retry_delay = self ._retry_delay ,force = False )
971
975
try :
972
976
return func (self ,* args ,** kwargs )
973
- except ldap . SERVER_DOWN :
977
+ except self . _reconnect_exceptions :
974
978
# Try to reconnect
975
979
self .reconnect (self ._uri ,retry_max = self ._retry_max ,retry_delay = self ._retry_delay ,force = True )
976
980
# Re-try last operation
0 commit comments