aboutsummaryrefslogtreecommitdiff
path: root/cros_utils/locks.py
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:24:56 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2020-04-28 20:24:56 +0000
commit656c7c0fa0d9b776c019f5423e01a9a28979d2bd (patch)
tree220a95d346d58fa5090d8033991bcfef2ad03d99 /cros_utils/locks.py
parent091406baac88deeb2ef9c71d5047bd9daf3915ef (diff)
parentccead650bb8e050400f55dc44b60f989b1f8e117 (diff)
downloadtoolchain-utils-q_tzdata_aml_297100000.tar.gz
Change-Id: I3464301d9b41d48e11dfd361a411d60a1bd5a429
Diffstat (limited to 'cros_utils/locks.py')
-rw-r--r--cros_utils/locks.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/cros_utils/locks.py b/cros_utils/locks.py
index 4ecbe0a9..cb96368e 100644
--- a/cros_utils/locks.py
+++ b/cros_utils/locks.py
@@ -1,29 +1,24 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2019 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
+# Copyright 2015 The Chromium OS Authors. All rights reserved.
"""Utilities for locking machines."""
from __future__ import print_function
import time
-import lock_machine
+import afe_lock_machine
import logger
def AcquireLock(machines, chromeos_root, timeout=1200):
- """Acquire lock for machine(s) with timeout."""
+ """Acquire lock for machine(s) with timeout, using AFE server for locking."""
start_time = time.time()
locked = True
sleep_time = min(10, timeout / 10.0)
while True:
try:
- lock_machine.LockManager(machines, False,
- chromeos_root).UpdateMachines(True)
+ afe_lock_machine.AFELockManager(machines, False, chromeos_root,
+ None).UpdateMachines(True)
break
except Exception as e:
if time.time() - start_time > timeout:
@@ -37,13 +32,13 @@ def AcquireLock(machines, chromeos_root, timeout=1200):
def ReleaseLock(machines, chromeos_root):
- """Release locked machine(s)."""
+ """Release locked machine(s), using AFE server for locking."""
unlocked = True
try:
- lock_machine.LockManager(machines, False,
- chromeos_root).UpdateMachines(False)
+ afe_lock_machine.AFELockManager(machines, False, chromeos_root,
+ None).UpdateMachines(False)
except Exception as e:
unlocked = False
- logger.GetLogger().LogWarning(
- 'Could not unlock %s. %s' % (repr(machines), str(e)))
+ logger.GetLogger().LogWarning('Could not unlock %s. %s' %
+ (repr(machines), str(e)))
return unlocked