mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-08-08 22:42:32 -04:00
good smarter killing of chrome
This commit is contained in:
parent
1ae9b83dab
commit
c6bd2417d7
1 changed files with 17 additions and 3 deletions
|
@ -228,7 +228,21 @@ class Chrome:
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
|
|
||||||
def __exit__(self, *args):
|
def __exit__(self, *args):
|
||||||
self.logger.info("killing chrome pid {}".format(self.chrome_process.pid))
|
timeout_sec = 60
|
||||||
os.killpg(self.chrome_process.pid, signal.SIGINT)
|
self.logger.info("terminating chrome pid {}".format(self.chrome_process.pid))
|
||||||
self.chrome_process.wait()
|
self.chrome_process.terminate()
|
||||||
|
start = time.time()
|
||||||
|
while time.time() - start < timeout_sec:
|
||||||
|
status = self.chrome_process.poll()
|
||||||
|
if status is not None:
|
||||||
|
if status == 0:
|
||||||
|
self.logger.info("chrome pid {} exited normally".format(self.chrome_process.pid, status))
|
||||||
|
else:
|
||||||
|
self.logger.warn("chrome pid {} exited with nonzero status {}".format(self.chrome_process.pid, status))
|
||||||
|
return
|
||||||
|
time.sleep(0.5)
|
||||||
|
|
||||||
|
self.logger.warn("chrome pid {} still alive {} seconds after sending SIGTERM, sending SIGKILL".format(self.chrome_process.pid, timeout_sec))
|
||||||
|
self.chrome_process.kill()
|
||||||
|
status = self.chrome_process.wait()
|
||||||
|
self.logger.warn("chrome pid {} reaped (status={}) after killing with SIGKILL".format(self.chrome_process.pid, status))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue