Skip to content

Commit

Permalink
Fix start_app timeout mechanism which assumes _is_app_running() retur… (
Browse files Browse the repository at this point in the history
#186)

* Fix start_app timeout mechanism which assumes _is_app_running() returns immediately.
Previously, this was looping for
wait_time x (1+_SOCKET_CONNECTION_TIMEOUT+_SOCKET_READ_TIMEOUT) seconds
instead of
wait_time x (1) seconds
  • Loading branch information
dthkao committed Apr 18, 2017
1 parent db46aff commit 65c752d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mobly/controllers/android_device_lib/jsonrpc_client_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,19 +175,21 @@ def start_app(self, wait_time=APP_START_WAIT_TIME):
"""Starts the server app on the android device.
Args:
wait_time: float, The time to wait for the app to come up before
raising an error.
wait_time: int, The minimum number of seconds to wait for the app
to come up before raising an error. Note that _is_app_running()
may take longer than wait_time.
Raises:
AppStartError: When the app was not able to be started.
"""
self.check_app_installed()
self._do_start_app()
for _ in range(wait_time):
time.sleep(1)
expiration_time = time.time() + wait_time
while time.time() < expiration_time:
if self._is_app_running():
self._log.debug('Successfully started %s', self.app_name)
return
time.sleep(1)
raise AppStartError('%s failed to start on %s.' %
(self.app_name, self._adb.serial))

Expand Down

0 comments on commit 65c752d

Please sign in to comment.