Bug 1632391 - [raptor] Fix timeout handling when shutting down the application. r=perftest-reviewers,sparky

Sleeping a second and increasing the elapsed time by 1,
doesn't mean that exactly a second has been passed-by.

For a better timeout handling the end time has to be
calculated first, and then checked against.

Differential Revision: https://phabricator.services.mozilla.com/D72132
This commit is contained in:
Henrik Skupin 2020-04-29 05:29:43 +00:00
Родитель add5457732
Коммит 5b204a623f
1 изменённых файлов: 14 добавлений и 11 удалений

Просмотреть файл

@ -99,7 +99,9 @@ class WebExtension(Perftest):
# we also need to give time for results processing, not just page/browser cycles!
timeout += 60
elapsed_time = 0
# stop 5 seconds early
end_time = time.time() + timeout - 5
while not self.control_server._finished:
# Ignore check if the control server shutdown the app
if not self.control_server._is_shutting_down:
@ -116,12 +118,13 @@ class WebExtension(Perftest):
self.cpu_profiler.generate_android_cpu_profile(test["name"])
self.control_server_wait_continue()
# Sleep for a moment to not check the process too often
time.sleep(1)
# we only want to force browser-shutdown on timeout if not in debug mode;
# in debug-mode we leave the browser running (require manual shutdown)
if not self.debug_mode:
elapsed_time += 1
if elapsed_time > (timeout) - 5: # stop 5 seconds early
if not self.debug_mode and end_time < time.time():
self.control_server.wait_for_quit()
if not self.control_server.is_webextension_loaded: