Index: build/android/pylib/chrome_test_server_spawner.py |
diff --git a/build/android/pylib/chrome_test_server_spawner.py b/build/android/pylib/chrome_test_server_spawner.py |
index 676939bc17d34b3aed4bcc287609af929f9b2b05..7f24ffb1968b5671387f75676c7f4ddfd473650e 100644 |
--- a/build/android/pylib/chrome_test_server_spawner.py |
+++ b/build/android/pylib/chrome_test_server_spawner.py |
@@ -45,6 +45,7 @@ SERVER_TYPES = { |
# The timeout (in seconds) of starting up the Python test server. |
TEST_SERVER_STARTUP_TIMEOUT = 10 |
+INITIAL_SLEEP_TIMEOUT_SEC = 0.025 |
def _CheckPortStatus(port, expected_status): |
"""Returns True if port has expected_status. |
@@ -56,10 +57,12 @@ def _CheckPortStatus(port, expected_status): |
Returns: |
Returns True if the status is expected. Otherwise returns False. |
""" |
- for timeout in range(1, 5): |
+ sleep_time_sec = INITIAL_SLEEP_TIMEOUT_SEC |
+ for attempt in range(1, 5): |
if ports.IsHostPortUsed(port) == expected_status: |
return True |
- time.sleep(timeout) |
+ time.sleep(sleep_time_sec) |
+ sleep_time_sec *= 2 |
return False |
@@ -231,17 +234,21 @@ class TestServerThread(threading.Thread): |
device_port = self._test_server_forwarder.DevicePortForHostPort( |
self.host_port) |
if device_port: |
- for timeout in range(1, 5): |
+ sleep_time_sec = INITIAL_SLEEP_TIMEOUT_SEC |
+ for attempt in range(1, 5): |
if ports.IsDevicePortUsed(self.adb, device_port, 'LISTEN'): |
self.is_ready = True |
self.forwarder_device_port = device_port |
break |
- time.sleep(timeout) |
+ time.sleep(sleep_time_sec) |
+ sleep_time_sec *= 2 |
bulach
2013/05/07 15:09:28
perhaps move this out into a "_CheckDevicePortStat
Philippe
2013/05/07 15:47:41
Good idea. I would not encourage people to use thi
|
# Wake up the request handler thread. |
self.ready_event.set() |
# Keep thread running until Stop() gets called. |
+ sleep_time_sec = INITIAL_SLEEP_TIMEOUT_SEC |
while not self.stop_flag: |
- time.sleep(1) |
+ time.sleep(sleep_time_sec) |
+ sleep_time_sec *= 2 |
bulach
2013/05/07 15:09:28
should we limit this somehow up to say, 1 or two s
Philippe
2013/05/07 15:47:41
Yeah good point.
|
if self.process.poll() is None: |
self.process.kill() |
if self._test_server_forwarder: |
@@ -401,7 +408,6 @@ class SpawningServer(object): |
listener_thread = threading.Thread(target=self._Listen) |
listener_thread.setDaemon(True) |
listener_thread.start() |
- time.sleep(1) |
def Stop(self): |
"""Stops the test server spawner. |