Skip to content

Commit

Permalink
Document Redlock.__init__() kwargs in docstrings (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
brainix authored Jan 12, 2022
1 parent b97c359 commit 645d038
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions pottery/redlock.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,25 @@ def __init__(self,
context_manager_blocking: bool = True,
context_manager_timeout: float = -1,
) -> None:
'''Initialize a Redlock.
Keyword arguments:
key -- a string that identifies your resource
masters -- the Redis clients used to achieve quorum for this
Redlock's state
raise_on_redis_errors -- whether to raise the QuorumIsImplssible
exception when too many Redis masters throw errors
auto_release_time -- the timeout in milliseconds by which to
automatically release this Redlock, unless it's already been
released
num_extensions -- the number of times that this Redlock's lease can
be extended
context_manager_blocking -- when using this Redlock as a context
manager, whether to block when acquiring
context_manager_timeout -- if context_manager_blocking, how long to
wait when acquiring before giving up and raising the
QuorumNotAchieved exception
'''
if not context_manager_blocking and context_manager_timeout != -1:
raise ValueError("can't specify a timeout for a non-blocking call")

Expand Down Expand Up @@ -689,6 +708,23 @@ def synchronize(*,
function at a time. Under the hood, synchronize() uses a Redlock. See
help(Redlock) for more details.
Keyword arguments:
key -- a string that identifies your resource
masters -- the Redis clients used to achieve quorum for this Redlock's
state
raise_on_redis_errors -- whether to raise the QuorumIsImplssible
exception when too many Redis masters throw errors
auto_release_time -- the timeout in milliseconds by which to
automatically release this Redlock, unless it's already been
released
num_extensions -- the number of times that this Redlock's lease can be
extended
context_manager_blocking -- when using this Redlock as a context
manager, whether to block when acquiring
context_manager_timeout -- if context_manager_blocking, how long to wait
when acquiring before giving up and raising the QuorumNotAchieved
exception
Usage:
>>> @synchronize(key='synchronized-func', auto_release_time=1500)
Expand Down

0 comments on commit 645d038

Please sign in to comment.