Skip to content

Commit e4a954a

Browse files
committed
adds missing modifications
1 parent 53229c6 commit e4a954a

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Diff for: redis/asyncio/cluster.py

+7
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ def lock(
839839
blocking_timeout: Optional[float] = None,
840840
lock_class: Optional[Type[Lock]] = None,
841841
thread_local: bool = True,
842+
raise_on_release_error: bool = True,
842843
) -> Lock:
843844
"""
844845
Return a new Lock object using key ``name`` that mimics
@@ -885,6 +886,11 @@ def lock(
885886
thread-1 would see the token value as "xyz" and would be
886887
able to successfully release the thread-2's lock.
887888
889+
``raise_on_release_error`` indicates whether to raise an exception when
890+
the lock is no longer owned when exiting the context manager. By default,
891+
this is True, meaning an exception will be raised. If False, the warning
892+
will be logged and the exception will be suppressed.
893+
888894
In some use cases it's necessary to disable thread local storage. For
889895
example, if you have code where one thread acquires a lock and passes
890896
that lock instance to a worker thread to release later. If thread
@@ -902,6 +908,7 @@ def lock(
902908
blocking=blocking,
903909
blocking_timeout=blocking_timeout,
904910
thread_local=thread_local,
911+
raise_on_release_error=raise_on_release_error,
905912
)
906913

907914

Diff for: redis/cluster.py

+7
Original file line numberDiff line numberDiff line change
@@ -822,6 +822,7 @@ def lock(
822822
blocking_timeout=None,
823823
lock_class=None,
824824
thread_local=True,
825+
raise_on_release_error: bool = True,
825826
):
826827
"""
827828
Return a new Lock object using key ``name`` that mimics
@@ -868,6 +869,11 @@ def lock(
868869
thread-1 would see the token value as "xyz" and would be
869870
able to successfully release the thread-2's lock.
870871
872+
``raise_on_release_error`` indicates whether to raise an exception when
873+
the lock is no longer owned when exiting the context manager. By default,
874+
this is True, meaning an exception will be raised. If False, the warning
875+
will be logged and the exception will be suppressed.
876+
871877
In some use cases it's necessary to disable thread local storage. For
872878
example, if you have code where one thread acquires a lock and passes
873879
that lock instance to a worker thread to release later. If thread
@@ -885,6 +891,7 @@ def lock(
885891
blocking=blocking,
886892
blocking_timeout=blocking_timeout,
887893
thread_local=thread_local,
894+
raise_on_release_error=raise_on_release_error,
888895
)
889896

890897
def set_response_callback(self, command, callback):

0 commit comments

Comments
 (0)