Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(163)

Side by Side Diff: client/bin/site_utils.py

Issue 1565001: test: Clean up site_login.py a bit. (Closed)
Patch Set: update one more call to attempt_logout() Created 10 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import time
6 from autotest_lib.client.common_lib import error
7
8
9 def poll_for_condition(
10 condition, exception=None, timeout=10, sleep_interval=0.1):
11 """Poll until a condition becomes true.
12
13 condition: function taking no args and returning bool
14 exception: exception to throw if condition doesn't become true
15 timeout: maximum number of seconds to wait
16 sleep_interval: time to sleep between polls
17
18 Raises:
19 'exception' arg if supplied; error.TestError otherwise
20 """
21 start_time = time.time()
22 while True:
23 if condition():
24 return
25 if time.time() + sleep_interval - start_time > timeout:
26 raise exception if exception else error.TestError(
27 'Timed out waiting for condition')
28 time.sleep(sleep_interval)
OLDNEW
« no previous file with comments | « client/bin/site_ui_test.py ('k') | client/site_tests/desktopui_ChromeFirstRender/desktopui_ChromeFirstRender.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698