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

Function list_locks

ci/util/lock_admin.py:30–93  ·  view source on GitHub ↗

List all locks in cache directory with status.

(cache_dir: Path)

Source from the content-addressed store, hash-verified

28
29
30def list_locks(cache_dir: Path) -> int:
31 """List all locks in cache directory with status."""
32 locks = list_active_locks(cache_dir)
33
34 # Also show all locks from the database
35 db = get_lock_database()
36 all_db_locks = db.list_all_locks()
37
38 if not locks and not all_db_locks:
39 print("No locks found")
40 return 0
41
42 print(f"\n📋 ACTIVE LOCKS")
43 print("=" * 80)
44
45 active_count = 0
46 stale_count = 0
47
48 # Show locks from cache_dir filtering
49 for lock in locks:
50 status_icon = "🔴 STALE" if lock.is_stale else "🟢 ACTIVE"
51 pid = lock.pid if lock.pid else "unknown"
52 operation = lock.operation
53 timestamp = lock.timestamp if lock.timestamp else "unknown"
54 hostname = lock.hostname if lock.hostname else "unknown"
55
56 if lock.is_stale:
57 stale_count += 1
58 else:
59 active_count += 1
60
61 print(f"\n{status_icon}")
62 print(f" Lock: {lock.path}")
63 print(f" PID: {pid}")
64 print(f" Operation: {operation}")
65 print(f" Timestamp: {timestamp}")
66 print(f" Hostname: {hostname}")
67
68 # Show any DB locks not already shown
69 shown_names = {lock.path for lock in locks}
70 for db_lock in all_db_locks:
71 lock_name = db_lock["lock_name"]
72 if lock_name not in shown_names:
73 pid = db_lock["owner_pid"]
74 alive = is_process_alive(pid)
75 status_icon = "🟢 ACTIVE" if alive else "🔴 STALE"
76
77 if alive:
78 active_count += 1
79 else:
80 stale_count += 1
81
82 print(f"\n{status_icon}")
83 print(f" Lock: {lock_name}")
84 print(f" PID: {pid}")
85 print(f" Operation: {db_lock['operation']}")
86 print(f" Mode: {db_lock['lock_mode']}")
87 print(f" Hostname: {db_lock['hostname']}")

Callers 1

mainFunction · 0.85

Calls 5

list_active_locksFunction · 0.90
get_lock_databaseFunction · 0.90
is_process_aliveFunction · 0.90
list_all_locksMethod · 0.80
printFunction · 0.50

Tested by

no test coverage detected