From a57b4fbf712cf5e5ec2fa3f1f2dacac33aefcd35 Mon Sep 17 00:00:00 2001 From: "ahe@google.com" Date: Mon, 5 Nov 2012 06:17:33 +0000 Subject: [PATCH] Prevent hanging if selenium cannot close browser. Review URL: https://codereview.chromium.org//11275125 git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14511 260f80e4-7a28-3924-810f-c04153c831b5 --- tools/testing/run_selenium.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tools/testing/run_selenium.py b/tools/testing/run_selenium.py index 322f560617d..001c088a3b9 100755 --- a/tools/testing/run_selenium.py +++ b/tools/testing/run_selenium.py @@ -40,6 +40,7 @@ import socket import sys import time import urllib2 +import threading TIMEOUT_ERROR_MSG = 'FAIL (timeout)' @@ -315,9 +316,27 @@ def run_batch_tests(): print '>>> TEST FAIL' sys.stdout.flush() finally: + sys.stdin.close() print("Closing browser"); - close_browser(browser) + def close_output_streams: + sys.stdout.flush() + sys.stdout.close() + sys.stderr.flush() + sys.stderr.close() + + def close_and_exit: + print("Timed out waiting for browser to close") + close_output_streams() + exit(1) + + timer = threading.Timer(5.0, close_and_exit) + timer.start() + try: + close_browser(browser) + timer.cancel() + finally: + close_output_streams() def main(args): # Run in batch mode if the --batch flag is passed.