even more patience killing chrome, send another sigterms every ten seconds if chrome is still alive

This commit is contained in:
Noah Levitt 2014-06-02 12:09:15 -07:00
parent c6bd2417d7
commit 1f91018d91

View File

@ -230,9 +230,13 @@ class Chrome:
def __exit__(self, *args):
timeout_sec = 60
self.logger.info("terminating chrome pid {}".format(self.chrome_process.pid))
self.chrome_process.terminate()
start = time.time()
while time.time() - start < timeout_sec:
first_sigterm = last_sigterm = time.time()
while time.time() - first_sigterm < timeout_sec:
time.sleep(0.5)
status = self.chrome_process.poll()
if status is not None:
if status == 0:
@ -240,7 +244,11 @@ class Chrome:
else:
self.logger.warn("chrome pid {} exited with nonzero status {}".format(self.chrome_process.pid, status))
return
time.sleep(0.5)
# sometimes a hung chrome process will terminate on repeated sigterms
if time.time() - last_sigterm > 10:
self.chrome_process.terminate()
last_sigterm = time.time()
self.logger.warn("chrome pid {} still alive {} seconds after sending SIGTERM, sending SIGKILL".format(self.chrome_process.pid, timeout_sec))
self.chrome_process.kill()