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

Side by Side Diff: tools/chrome_remote_control/chrome_remote_control/util.py

Issue 11361165: [chrome_remote_control] Rename chrome_remote_control to telemetry. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 # Copyright (c) 2012 The Chromium 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 import inspect
5 import time
6
7 class TimeoutException(Exception):
8 pass
9
10 def WaitFor(condition,
11 timeout, poll_interval=0.1,
12 pass_time_left_to_func=False):
13 assert isinstance(condition, type(lambda: None)) # is function
14 start_time = time.time()
15 while True:
16 if pass_time_left_to_func:
17 res = condition((start_time + timeout) - time.time())
18 else:
19 res = condition()
20 if res:
21 break
22 if time.time() - start_time > timeout:
23 if condition.__name__ == '<lambda>':
24 try:
25 condition_string = inspect.getsource(condition).strip()
26 except IOError:
27 condition_string = condition.__name__
28 else:
29 condition_string = condition.__name__
30 raise TimeoutException('Timed out while waiting %ds for %s.' %
31 (timeout, condition_string))
32 time.sleep(poll_interval)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698