MCPcopy
hub / github.com/redis/redis-py / extend

Method extend

redis/lock.py:287–304  ·  view source on GitHub ↗

Adds more time to an already acquired lock. ``additional_time`` can be specified as an integer or a float, both representing the number of seconds to add. ``replace_ttl`` if False (the default), add `additional_time` to the lock's existing ttl. If True, rep

(
        self, additional_time: Number, replace_ttl: bool = False
    )

Source from the content-addressed store, hash-verified

285 )
286
287 def extend(
288 self, additional_time: Number, replace_ttl: bool = False
289 ) -> Literal[True]:
290 """
291 Adds more time to an already acquired lock.
292
293 ``additional_time`` can be specified as an integer or a float, both
294 representing the number of seconds to add.
295
296 ``replace_ttl`` if False (the default), add `additional_time` to
297 the lock's existing ttl. If True, replace the lock's ttl with
298 `additional_time`.
299 """
300 if self.local.token is None:
301 raise LockError("Cannot extend an unlocked lock", lock_name=self.name)
302 if self.timeout is None:
303 raise LockError("Cannot extend a lock with no timeout", lock_name=self.name)
304 return self.do_extend(additional_time, replace_ttl)
305
306 def do_extend(self, additional_time: Number, replace_ttl: bool) -> Literal[True]:
307 additional_time = int(additional_time * 1000)

Calls 2

do_extendMethod · 0.95
LockErrorClass · 0.90