Commit 1d0da27a authored by Tatiana Buldina's avatar Tatiana Buldina Committed by Commit Bot

[ChromeDriver] Add timeout to waiting for ChromeDriver to shut down

Bug: chromedriver:3042
Change-Id: I8ebec3e58904e63926aa276902c7a92559c8ab66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1785681Reviewed-by: default avatarJohn Chen <johnchen@chromium.org>
Commit-Queue: Tatiana Buldina <buldina@chromium.org>
Cr-Commit-Position: refs/heads/master@{#693810}
parent ca55fac5
...@@ -6,9 +6,23 @@ import atexit ...@@ -6,9 +6,23 @@ import atexit
import os import os
import socket import socket
import subprocess import subprocess
import threading
import time import time
import urllib2 import urllib2
def terminate_process(proc):
"""Terminates the process.
If an error occurs ignore it, just print out a message.
Args:
proc: A subprocess.
"""
try:
proc.terminate()
except OSError as ex:
print 'Error while killing a process: %s' % ex
class Server(object): class Server(object):
"""A running ChromeDriver server.""" """A running ChromeDriver server."""
...@@ -100,5 +114,8 @@ class Server(object): ...@@ -100,5 +114,8 @@ class Server(object):
urllib2.urlopen(self.GetUrl() + '/shutdown', timeout=10).close() urllib2.urlopen(self.GetUrl() + '/shutdown', timeout=10).close()
except: except:
self._process.terminate() self._process.terminate()
timer = threading.Timer(5, terminate_process, [self._process])
timer.start()
self._process.wait() self._process.wait()
timer.cancel()
self._process = None self._process = None
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment