MCPcopy Create free account
hub / github.com/Dispatcharr/Dispatcharr / _renew_loop

Method _renew_loop

core/utils.py:346–363  ·  view source on GitHub ↗

Background loop that extends the lock TTL until stopped.

(self)

Source from the content-addressed store, hash-verified

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."""

Callers

nothing calls this directly

Calls 4

get_clientMethod · 0.80
expireMethod · 0.80
waitMethod · 0.45
existsMethod · 0.45

Tested by

no test coverage detected