mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-08-08 14:32:23 -04:00
even more patience killing chrome, send another sigterms every ten seconds if chrome is still alive
This commit is contained in:
parent
c6bd2417d7
commit
1f91018d91
1 changed files with 11 additions and 3 deletions
|
@ -230,9 +230,13 @@ class Chrome:
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
timeout_sec = 60
|
timeout_sec = 60
|
||||||
self.logger.info("terminating chrome pid {}".format(self.chrome_process.pid))
|
self.logger.info("terminating chrome pid {}".format(self.chrome_process.pid))
|
||||||
|
|
||||||
self.chrome_process.terminate()
|
self.chrome_process.terminate()
|
||||||
start = time.time()
|
first_sigterm = last_sigterm = time.time()
|
||||||
while time.time() - start < timeout_sec:
|
|
||||||
|
while time.time() - first_sigterm < timeout_sec:
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
status = self.chrome_process.poll()
|
status = self.chrome_process.poll()
|
||||||
if status is not None:
|
if status is not None:
|
||||||
if status == 0:
|
if status == 0:
|
||||||
|
@ -240,7 +244,11 @@ class Chrome:
|
||||||
else:
|
else:
|
||||||
self.logger.warn("chrome pid {} exited with nonzero status {}".format(self.chrome_process.pid, status))
|
self.logger.warn("chrome pid {} exited with nonzero status {}".format(self.chrome_process.pid, status))
|
||||||
return
|
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.logger.warn("chrome pid {} still alive {} seconds after sending SIGTERM, sending SIGKILL".format(self.chrome_process.pid, timeout_sec))
|
||||||
self.chrome_process.kill()
|
self.chrome_process.kill()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue