@@ -820,8 +820,7 @@ def get_naming_contexts(self):
820820class ReconnectLDAPObject (SimpleLDAPObject ):
821821 """
822822 :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.
825824
826825 The first arguments are same as for the :py:func:`~ldap.initialize()`
827826 function.
@@ -833,6 +832,10 @@ class ReconnectLDAPObject(SimpleLDAPObject):
833832 * retry_delay: specifies the time in seconds between reconnect attempts.
834833
835834 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.
836839 """
837840
838841 __transient_attrs__ = {
@@ -842,6 +845,7 @@ class ReconnectLDAPObject(SimpleLDAPObject):
842845 '_reconnect_lock' ,
843846 '_last_bind' ,
844847 }
848+ _reconnect_exceptions = (ldap .SERVER_DOWN , ldap .UNAVAILABLE , ldap .CONNECT_ERROR , ldap .TIMEOUT )
845849
846850 def __init__ (
847851 self ,uri ,
@@ -974,7 +978,7 @@ def _apply_method_s(self,func,*args,**kwargs):
974978 self .reconnect (self ._uri ,retry_max = self ._retry_max ,retry_delay = self ._retry_delay ,force = False )
975979 try :
976980 return func (self ,* args ,** kwargs )
977- except ldap . SERVER_DOWN :
981+ except self . _reconnect_exceptions :
978982 # Try to reconnect
979983 self .reconnect (self ._uri ,retry_max = self ._retry_max ,retry_delay = self ._retry_delay ,force = True )
980984 # Re-try last operation
0 commit comments