25
25
SentinelCommands ,
26
26
list_or_args ,
27
27
)
28
- from redis .connection import ConnectionPool , SSLConnection , UnixDomainSocketConnection
28
+ from redis .connection import (
29
+ AbstractConnection ,
30
+ ConnectionPool ,
31
+ SSLConnection ,
32
+ UnixDomainSocketConnection ,
33
+ )
29
34
from redis .credentials import CredentialProvider
30
35
from redis .exceptions import (
31
36
ConnectionError ,
@@ -198,6 +203,7 @@ def __init__(
198
203
ssl_validate_ocsp_stapled = False ,
199
204
ssl_ocsp_context = None ,
200
205
ssl_ocsp_expected_cert = None ,
206
+ ssl_min_version = None ,
201
207
max_connections = None ,
202
208
single_connection_client = False ,
203
209
health_check_interval = 0 ,
@@ -311,6 +317,7 @@ def __init__(
311
317
"ssl_validate_ocsp" : ssl_validate_ocsp ,
312
318
"ssl_ocsp_context" : ssl_ocsp_context ,
313
319
"ssl_ocsp_expected_cert" : ssl_ocsp_expected_cert ,
320
+ "ssl_min_version" : ssl_min_version ,
314
321
}
315
322
)
316
323
connection_pool = ConnectionPool (** kwargs )
@@ -837,11 +844,15 @@ def clean_health_check_responses(self) -> None:
837
844
def _disconnect_raise_connect (self , conn , error ) -> None :
838
845
"""
839
846
Close the connection and raise an exception
840
- if retry_on_timeout is not set or the error
841
- is not a TimeoutError. Otherwise, try to reconnect
847
+ if retry_on_error is not set or the error is not one
848
+ of the specified error types. Otherwise, try to
849
+ reconnect
842
850
"""
843
851
conn .disconnect ()
844
- if not (conn .retry_on_timeout and isinstance (error , TimeoutError )):
852
+ if (
853
+ conn .retry_on_error is None
854
+ or isinstance (error , tuple (conn .retry_on_error )) is False
855
+ ):
845
856
raise error
846
857
conn .connect ()
847
858
@@ -1318,8 +1329,8 @@ def _disconnect_reset_raise(self, conn, error) -> None:
1318
1329
"""
1319
1330
Close the connection, reset watching state and
1320
1331
raise an exception if we were watching,
1321
- retry_on_timeout is not set,
1322
- or the error is not a TimeoutError
1332
+ if retry_on_error is not set or the error is not one
1333
+ of the specified error types.
1323
1334
"""
1324
1335
conn .disconnect ()
1325
1336
# if we were already watching a variable, the watch is no longer
@@ -1330,9 +1341,12 @@ def _disconnect_reset_raise(self, conn, error) -> None:
1330
1341
raise WatchError (
1331
1342
"A ConnectionError occurred on while watching one or more keys"
1332
1343
)
1333
- # if retry_on_timeout is not set, or the error is not
1334
- # a TimeoutError, raise it
1335
- if not (conn .retry_on_timeout and isinstance (error , TimeoutError )):
1344
+ # if retry_on_error is not set or the error is not one
1345
+ # of the specified error types, raise it
1346
+ if (
1347
+ conn .retry_on_error is None
1348
+ or isinstance (error , tuple (conn .retry_on_error )) is False
1349
+ ):
1336
1350
self .reset ()
1337
1351
raise
1338
1352
@@ -1490,11 +1504,15 @@ def load_scripts(self):
1490
1504
if not exist :
1491
1505
s .sha = immediate ("SCRIPT LOAD" , s .script )
1492
1506
1493
- def _disconnect_raise_reset (self , conn : Redis , error : Exception ) -> None :
1507
+ def _disconnect_raise_reset (
1508
+ self ,
1509
+ conn : AbstractConnection ,
1510
+ error : Exception ,
1511
+ ) -> None :
1494
1512
"""
1495
1513
Close the connection, raise an exception if we were watching,
1496
- and raise an exception if TimeoutError is not part of retry_on_error,
1497
- or the error is not a TimeoutError
1514
+ and raise an exception if retry_on_error is not set or the
1515
+ error is not one of the specified error types.
1498
1516
"""
1499
1517
conn .disconnect ()
1500
1518
# if we were watching a variable, the watch is no longer valid
@@ -1504,11 +1522,13 @@ def _disconnect_raise_reset(self, conn: Redis, error: Exception) -> None:
1504
1522
raise WatchError (
1505
1523
"A ConnectionError occurred on while watching one or more keys"
1506
1524
)
1507
- # if TimeoutError is not part of retry_on_error, or the error
1508
- # is not a TimeoutError, raise it
1509
- if not (
1510
- TimeoutError in conn .retry_on_error and isinstance (error , TimeoutError )
1525
+ # if retry_on_error is not set or the error is not one
1526
+ # of the specified error types, raise it
1527
+ if (
1528
+ conn .retry_on_error is None
1529
+ or isinstance (error , tuple (conn .retry_on_error )) is False
1511
1530
):
1531
+
1512
1532
self .reset ()
1513
1533
raise error
1514
1534
0 commit comments