From 7e36ee16487f20f463aa25ee190c53ad04785e9f Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 9 Mar 2021 21:01:42 -0800 Subject: [PATCH] Tools: Add exponential backoff retrying, print last result --- tools/perf.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/perf.py b/tools/perf.py index 75f05fb7f..ebec111e5 100755 --- a/tools/perf.py +++ b/tools/perf.py @@ -71,6 +71,7 @@ class GameClockTest(PerfTest): class PerfServer(object): ITERATIONS_PER_INSTANCE = 50 + RETRIES = 5 def __init__(self, address, root='/', command=None): s = address.rsplit(':', 1) @@ -100,8 +101,17 @@ class PerfServer(object): elif test.renderer == 'threaded-software': server_command.append('-T') subprocess.check_call(server_command) - time.sleep(4) - self.socket = socket.create_connection(self.address, timeout=1000) + time.sleep(1) + for backoff in range(self.RETRIES): + try: + self.socket = socket.create_connection(self.address, timeout=1000) + break + except OSError as e: + print("Failed to connect:", e) + if backoff < self.RETRIES - 1: + time.sleep(2 ** backoff) + else: + raise kwargs = {} if sys.version_info[0] >= 3: kwargs["encoding"] = "utf-8" @@ -158,6 +168,7 @@ class Suite(object): print('Running test {}'.format(test.name), file=sys.stderr) if self.server: self.server.run(test) + print(self.server.results[-1]) else: try: test.run(self.cwd)