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

Function list_active_locks

ci/util/cache_lock.py:164–202  ·  view source on GitHub ↗

List all active locks in cache directory with metadata. Args: cache_dir: Global cache directory Returns: List of LockInfo objects

(cache_dir: Path)

Source from the content-addressed store, hash-verified

162
163
164def list_active_locks(cache_dir: Path) -> list[LockInfo]:
165 """
166 List all active locks in cache directory with metadata.
167
168 Args:
169 cache_dir: Global cache directory
170
171 Returns:
172 List of LockInfo objects
173 """
174 if not cache_dir.exists():
175 return []
176
177 locks: list[LockInfo] = []
178
179 # Query database for all locks
180 db = get_lock_database()
181 all_db_locks = db.list_all_locks()
182
183 from ci.util.file_lock_rw_util import is_process_alive
184
185 for lock in all_db_locks:
186 # Filter to locks relevant to this cache_dir
187 lock_name = lock["lock_name"]
188 if str(cache_dir) in lock_name:
189 pid = lock["owner_pid"]
190 stale = not is_process_alive(pid)
191 locks.append(
192 LockInfo(
193 path=lock_name,
194 pid=pid,
195 operation=lock["operation"],
196 timestamp=str(lock["acquired_at"]),
197 is_stale=stale,
198 hostname=lock["hostname"],
199 )
200 )
201
202 return locks
203
204
205def is_artifact_locked(cache_dir: Path, url: str) -> bool:

Callers 3

test_list_empty_cacheMethod · 0.90
list_locksFunction · 0.90

Calls 5

get_lock_databaseFunction · 0.90
is_process_aliveFunction · 0.90
LockInfoClass · 0.85
list_all_locksMethod · 0.80
appendMethod · 0.45

Tested by 2

test_list_empty_cacheMethod · 0.72