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
)
| 294 | raise LockNotOwnedError("Cannot release a lock that's no longer owned") |
| 295 | |
| 296 | def extend( |
| 297 | self, additional_time: Number, replace_ttl: bool = False |
| 298 | ) -> Awaitable[Literal[True]]: |
| 299 | """ |
| 300 | Adds more time to an already acquired lock. |
| 301 | |
| 302 | ``additional_time`` can be specified as an integer or a float, both |
| 303 | representing the number of seconds to add. |
| 304 | |
| 305 | ``replace_ttl`` if False (the default), add `additional_time` to |
| 306 | the lock's existing ttl. If True, replace the lock's ttl with |
| 307 | `additional_time`. |
| 308 | """ |
| 309 | if self.local.token is None: |
| 310 | raise LockError("Cannot extend an unlocked lock") |
| 311 | if self.timeout is None: |
| 312 | raise LockError("Cannot extend a lock with no timeout") |
| 313 | return self.do_extend(additional_time, replace_ttl) |
| 314 | |
| 315 | async def do_extend(self, additional_time, replace_ttl) -> Literal[True]: |
| 316 | additional_time = int(additional_time * 1000) |
no test coverage detected