MCPcopy Create free account
hub / github.com/FastLED/FastLED / break_stale_lock

Method break_stale_lock

ci/util/lock_database.py:277–308  ·  view source on GitHub ↗

Remove rows where owner PID is dead. Args: lock_name: Name identifying the lock Returns: True if any stale locks were removed

(self, lock_name: str)

Source from the content-addressed store, hash-verified

275 return True
276
277 def break_stale_lock(self, lock_name: str) -> bool:
278 """Remove rows where owner PID is dead.
279
280 Args:
281 lock_name: Name identifying the lock
282
283 Returns:
284 True if any stale locks were removed
285 """
286 holders = self.get_lock_info(lock_name)
287 if not holders:
288 return False
289
290 removed = False
291 conn = self._get_connection()
292 try:
293 cursor = conn.cursor()
294 for holder in holders:
295 pid = holder["owner_pid"]
296 if not is_process_alive(pid):
297 cursor.execute(
298 "DELETE FROM lock_holders WHERE lock_name = ? AND owner_pid = ?",
299 (lock_name, pid),
300 )
301 if cursor.rowcount > 0:
302 removed = True
303 logger.info(f"Broke stale lock: {lock_name} (dead PID {pid})")
304 conn.commit()
305 finally:
306 conn.close()
307
308 return removed
309
310 def force_break(self, lock_name: str) -> bool:
311 """Unconditionally remove all holders for a lock.

Callers 7

_check_stale_lockMethod · 0.80
_check_stale_lockMethod · 0.80
test_break_stale_lockMethod · 0.80
check_lockFunction · 0.80
break_stale_lockFunction · 0.80
__enter__Method · 0.80

Calls 7

get_lock_infoMethod · 0.95
_get_connectionMethod · 0.95
is_process_aliveFunction · 0.90
executeMethod · 0.80
commitMethod · 0.80
infoMethod · 0.45
closeMethod · 0.45

Tested by 2

test_break_stale_lockMethod · 0.64