Commit 18d8eec1 authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

Add timeout to chrome-proxy ChromeDriver emulation server start

bustamanate@ reports occasional hanging on tests that use the
emulation server. This CL adds a timeout to ensure that a test
run doesn't totally hang because of a flake here.

Bug: 823776
Change-Id: I28bc040be9f9ae606f6b75481d2bf8dc21cc6957
Reviewed-on: https://chromium-review.googlesource.com/993272
Commit-Queue: Robert Ogden <robertogden@google.com>
Reviewed-by: default avatarScott Little <sclittle@chromium.org>
Cr-Commit-Position: refs/heads/master@{#547774}
parent 4bf1fe96
......@@ -82,12 +82,15 @@ class LocalEmulationServer:
self._server_class = server_class
self._server = None
def StartAndReturn(self):
def StartAndReturn(self, timeout=30):
"""Start the server in a new thread and return once the server is running.
A new server of the given server_class at init is started with the given
handler. The server will listen forever in a new thread unless Shutdown() is
called.
Args:
timeout: The timeout to start the server.
"""
self._server = self._server_class(("0.0.0.0", self._port),
self._handler_class)
......@@ -98,7 +101,8 @@ class LocalEmulationServer:
thread = threading.Thread(target=WaitForRunning, args=[event])
thread.daemon = True
thread.start()
event.wait()
if not event.wait(timeout=timeout):
raise Exception("Emulation server didn't start in %d seconds" % timeout)
def Shutdown(self):
"""Shutdown a running server.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment