Add delay after EC "hostevent set"

This adds a hard-coded delay after setting a hostevent to allow
enough time for the EC to process it.

FAFT will often perform a sequence that involves changing host event
flags followed by a reboot in order to change into a different mode.
Console commands can take a while to process, so this can create a
race condition whereby a physical button press gets processed earlier
than command.

BUG=chrome-os-partner:28249, chromium:371631
BRANCH=none
TEST="power button pressed" no longer seen before
"hostevent set 0x4000" in EC console during firmware_SelfSignedBoot
on Nyan

Change-Id: I9800105e1a7db54f6e1358f85fc28f57b259eb1b
Reviewed-on: https://chromium-review.googlesource.com/198970
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Reviewed-by: Yusuf Mohsinally <mohsinally@chromium.org>
Commit-Queue: David Hendricks <dhendrix@chromium.org>
Tested-by: David Hendricks <dhendrix@chromium.org>
diff --git a/server/cros/servo/chrome_ec.py b/server/cros/servo/chrome_ec.py
index 4363b6e..910e6b4 100644
--- a/server/cros/servo/chrome_ec.py
+++ b/server/cros/servo/chrome_ec.py
@@ -2,7 +2,7 @@
 # Use of this source code is governed by a BSD-style license that can be
 # found in the LICENSE file.
 
-import ast, logging, re
+import ast, logging, re, time
 
 from autotest_lib.client.common_lib import error
 
@@ -236,3 +236,7 @@
           codes: Hostevent codes, HOSTEVENT_*
         """
         self.send_command("hostevent set %#x" % codes)
+        # Allow enough time for EC to process input and set flag.
+        # See chromium:371631 for details.
+        # FIXME: Stop importing time module if this hack becomes obsolete.
+        time.sleep(1)