[autotest] Delay hosts module import in drone_utility
The hosts module import takes ~.75 seconds. This has been bottlenecking
the scheduler tick by slowing down each drone_utility refresh call by
~1.5 seconds. Delay the import as a hack while we work on a real fix.
BUG=chromium:718181
BUG=chromium:739466
TEST=None
Change-Id: I3966259594bc5b2e5e1dd8592c8dcfd9cbda1c6c
Reviewed-on: https://chromium-review.googlesource.com/559938
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/scheduler/drone_utility.py b/scheduler/drone_utility.py
index 9df8a02..dd4849d 100755
--- a/scheduler/drone_utility.py
+++ b/scheduler/drone_utility.py
@@ -38,7 +38,6 @@
from autotest_lib.scheduler import drone_logging_config
from autotest_lib.scheduler import email_manager
from autotest_lib.scheduler import scheduler_config
-from autotest_lib.server import hosts
from autotest_lib.server import subcommand
@@ -598,6 +597,9 @@
def create_host(hostname):
+ # TODO(crbug.com/739466) Delay import to avoid a ~0.7 second penalty
+ # drone_utility calls that don't actually interact with DUTs.
+ from autotest_lib.server import hosts
username = global_config.global_config.get_config_value(
'SCHEDULER', hostname + '_username', default=getpass.getuser())
return hosts.SSHHost(hostname, user=username)