Background loop that extends the lock TTL until stopped.
(self)
| 344 | self._thread = None |
| 345 | |
| 346 | def _renew_loop(self): |
| 347 | """Background loop that extends the lock TTL until stopped.""" |
| 348 | while not self._stop_event.wait(self.renewal_interval): |
| 349 | try: |
| 350 | redis_client = RedisClient.get_client() |
| 351 | if redis_client.exists(self.lock_id): |
| 352 | redis_client.expire(self.lock_id, self.ttl) |
| 353 | logger.debug( |
| 354 | f"Renewed lock {self.lock_id} TTL to {self.ttl}s" |
| 355 | ) |
| 356 | else: |
| 357 | # Lock was deleted externally (e.g. manual release) — stop renewing |
| 358 | logger.warning( |
| 359 | f"Lock {self.lock_id} no longer exists, stopping renewal" |
| 360 | ) |
| 361 | break |
| 362 | except Exception as e: |
| 363 | logger.error(f"Error renewing lock {self.lock_id}: {e}") |
| 364 | |
| 365 | def start(self): |
| 366 | """Start the background renewal thread.""" |
nothing calls this directly
no test coverage detected