import os LOCK_DIR = "/var/lib/otbcloud/locks" def _lock_path(name): return os.path.join(LOCK_DIR, f"{name}.lock") def is_locked(name): return os.path.exists(_lock_path(name)) def acquire(name): os.makedirs(LOCK_DIR, exist_ok=True) path = _lock_path(name) if os.path.exists(path): return False with open(path, "w") as f: f.write(str(os.getpid())) return True def release(name): path = _lock_path(name) if os.path.exists(path): os.remove(path) def select_processor(): if acquire("intel"): return "intel" if acquire("amd"): return "amd" return "cpu"