File tree 3 files changed +19
-6
lines changed 3 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,8 @@ def __init__(
368
368
]:
369
369
raise RedisError ("Client caching is only supported with RESP version 3" )
370
370
371
+ # TODO: To avoid breaking changes during the bug fix, we have to keep non-reentrant lock.
372
+ # TODO: Remove this before next major version (7.0.0)
371
373
self .single_connection_lock = threading .Lock ()
372
374
self .connection = None
373
375
self ._single_connection_client = single_connection_client
@@ -773,6 +775,9 @@ def __init__(
773
775
self ._event_dispatcher = EventDispatcher ()
774
776
else :
775
777
self ._event_dispatcher = event_dispatcher
778
+
779
+ # TODO: To avoid breaking changes during the bug fix, we have to keep non-reentrant lock.
780
+ # TODO: Remove this before next major version (7.0.0)
776
781
self ._lock = threading .Lock ()
777
782
if self .encoder is None :
778
783
self .encoder = self .connection_pool .get_encoder ()
Original file line number Diff line number Diff line change @@ -709,7 +709,7 @@ def __init__(
709
709
self .result_callbacks = CaseInsensitiveDict (self .__class__ .RESULT_CALLBACKS )
710
710
711
711
self .commands_parser = CommandsParser (self )
712
- self ._lock = threading .Lock ()
712
+ self ._lock = threading .RLock ()
713
713
714
714
def __enter__ (self ):
715
715
return self
@@ -1473,7 +1473,7 @@ def __init__(
1473
1473
self .connection_kwargs = kwargs
1474
1474
self .read_load_balancer = LoadBalancer ()
1475
1475
if lock is None :
1476
- lock = threading .Lock ()
1476
+ lock = threading .RLock ()
1477
1477
self ._lock = lock
1478
1478
if event_dispatcher is None :
1479
1479
self ._event_dispatcher = EventDispatcher ()
@@ -2177,7 +2177,7 @@ def __init__(
2177
2177
kwargs .get ("decode_responses" , False ),
2178
2178
)
2179
2179
if lock is None :
2180
- lock = threading .Lock ()
2180
+ lock = threading .RLock ()
2181
2181
self ._lock = lock
2182
2182
self .parent_execute_command = super ().execute_command
2183
2183
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