Skip to content

Commit f4a0be3

Browse files
committed
Avoid mutating a global retry_on_error list
1 parent 42b937f commit f4a0be3

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

redis/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ def __init__(
914914
errors=None,
915915
decode_responses=False,
916916
retry_on_timeout=False,
917-
retry_on_error=[],
917+
retry_on_error=None,
918918
ssl=False,
919919
ssl_keyfile=None,
920920
ssl_certfile=None,
@@ -958,6 +958,8 @@ def __init__(
958958
)
959959
)
960960
encoding_errors = errors
961+
if not retry_on_error:
962+
retry_on_error = []
961963
if retry_on_timeout is True:
962964
retry_on_error.append(TimeoutError)
963965
kwargs = {

redis/connection.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,7 +520,7 @@ def __init__(
520520
socket_keepalive_options=None,
521521
socket_type=0,
522522
retry_on_timeout=False,
523-
retry_on_error=[],
523+
retry_on_error=SENTINEL,
524524
encoding="utf-8",
525525
encoding_errors="strict",
526526
decode_responses=False,
@@ -552,6 +552,8 @@ def __init__(
552552
self.socket_keepalive_options = socket_keepalive_options or {}
553553
self.socket_type = socket_type
554554
self.retry_on_timeout = retry_on_timeout
555+
if retry_on_error is SENTINEL:
556+
retry_on_error = []
555557
if retry_on_timeout:
556558
# Add TimeoutError to the errors list to retry on
557559
retry_on_error.append(TimeoutError)
@@ -1071,7 +1073,7 @@ def __init__(
10711073
encoding_errors="strict",
10721074
decode_responses=False,
10731075
retry_on_timeout=False,
1074-
retry_on_error=[],
1076+
retry_on_error=SENTINEL,
10751077
parser_class=DefaultParser,
10761078
socket_read_size=65536,
10771079
health_check_interval=0,
@@ -1094,6 +1096,8 @@ def __init__(
10941096
self.password = password
10951097
self.socket_timeout = socket_timeout
10961098
self.retry_on_timeout = retry_on_timeout
1099+
if retry_on_error is SENTINEL:
1100+
retry_on_error = []
10971101
if retry_on_timeout:
10981102
# Add TimeoutError to the errors list to retry on
10991103
retry_on_error.append(TimeoutError)

0 commit comments

Comments
 (0)