File tree Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Expand file tree Collapse file tree 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -369,6 +369,8 @@ def __init__(
369
369
]:
370
370
raise RedisError ("Client caching is only supported with RESP version 3" )
371
371
372
+ # TODO: To avoid breaking changes during the bug fix, we have to keep non-reentrant lock.
373
+ # TODO: Remove this before next major version (7.0.0)
372
374
self .single_connection_lock = threading .Lock ()
373
375
self .connection = None
374
376
self ._single_connection_client = single_connection_client
@@ -774,6 +776,9 @@ def __init__(
774
776
self ._event_dispatcher = EventDispatcher ()
775
777
else :
776
778
self ._event_dispatcher = event_dispatcher
779
+
780
+ # TODO: To avoid breaking changes during the bug fix, we have to keep non-reentrant lock.
781
+ # TODO: Remove this before next major version (7.0.0)
777
782
self ._lock = threading .Lock ()
778
783
if self .encoder is None :
779
784
self .encoder = self .connection_pool .get_encoder ()
Original file line number Diff line number Diff line change @@ -710,7 +710,7 @@ def __init__(
710
710
self .result_callbacks = CaseInsensitiveDict (self .__class__ .RESULT_CALLBACKS )
711
711
712
712
self .commands_parser = CommandsParser (self )
713
- self ._lock = threading .Lock ()
713
+ self ._lock = threading .RLock ()
714
714
715
715
def __enter__ (self ):
716
716
return self
@@ -1474,7 +1474,7 @@ def __init__(
1474
1474
self .connection_kwargs = kwargs
1475
1475
self .read_load_balancer = LoadBalancer ()
1476
1476
if lock is None :
1477
- lock = threading .Lock ()
1477
+ lock = threading .RLock ()
1478
1478
self ._lock = lock
1479
1479
if event_dispatcher is None :
1480
1480
self ._event_dispatcher = EventDispatcher ()
@@ -2178,7 +2178,7 @@ def __init__(
2178
2178
kwargs .get ("decode_responses" , False ),
2179
2179
)
2180
2180
if lock is None :
2181
- lock = threading .Lock ()
2181
+ lock = threading .RLock ()
2182
2182
self ._lock = lock
2183
2183
self .parent_execute_command = super ().execute_command
2184
2184
self ._execution_strategy : ExecutionStrategy = (
Original file line number Diff line number Diff line change @@ -820,7 +820,7 @@ def __init__(
820
820
self .credential_provider = conn .credential_provider
821
821
self ._pool_lock = pool_lock
822
822
self ._cache = cache
823
- self ._cache_lock = threading .Lock ()
823
+ self ._cache_lock = threading .RLock ()
824
824
self ._current_command_cache_key = None
825
825
self ._current_options = None
826
826
self .register_connect_callback (self ._enable_tracking_callback )
@@ -1420,8 +1420,16 @@ def __init__(
1420
1420
# object of this pool. subsequent threads acquiring this lock
1421
1421
# will notice the first thread already did the work and simply
1422
1422
# release the lock.
1423
- self ._fork_lock = threading .Lock ()
1424
- self ._lock = threading .Lock ()
1423
+
1424
+ self ._fork_lock = threading .RLock ()
1425
+
1426
+ if self .cache is None :
1427
+ self ._lock = threading .RLock ()
1428
+ else :
1429
+ # TODO: To avoid breaking changes during the bug fix, we have to keep non-reentrant lock.
1430
+ # TODO: Remove this before next major version (7.0.0)
1431
+ self ._lock = threading .Lock ()
1432
+
1425
1433
self .reset ()
1426
1434
1427
1435
def __repr__ (self ) -> (str , str ):
You can’t perform that action at this time.
0 commit comments