Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2068)

Unified Diff: scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py

Issue 2386073002: Wait cloudtail termination in goma module (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py
diff --git a/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py b/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py
index 79f20dc1edd7c1ee81c9d20086e9b363e61c5bb5..6945bb9f93e7d2e2b614bc7370740e7e73155223 100644
--- a/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py
+++ b/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py
@@ -9,6 +9,7 @@ import os
import signal
import subprocess
import sys
+import time
from slave import goma_utils
@@ -24,6 +25,15 @@ def start_cloudtail(args):
with open(args.pid_file, 'w') as f:
f.write(str(proc.pid))
+def is_running_posix(pid):
+ try:
+ os.kill(pid, 0)
+ except OSError as e:
+ if e.errno == errno.ESRCH:
ukai 2016/10/03 02:52:52 kill may get errno.EPERM and I think we should ret
Vadim Sh. 2016/10/03 19:07:06 +1 for EPERM handling and returning false
tikuta 2016/10/04 03:45:26 Done.
+ return False
+ raise e
Yoshisato Yanagisawa 2016/10/03 04:49:05 So, in this case, we do not guarantee cloud tail d
tikuta 2016/10/04 03:45:25 I send SIGKILL
+ return True
+
def main():
parser = argparse.ArgumentParser(
description='cloudtail utility for goma recipe module.')
@@ -52,7 +62,16 @@ def main():
with open(args.killed_pid_file) as f:
# cloudtail flushes log and terminates
# within 5 seconds when it recieves SIGINT.
- os.kill(int(f.read()), signal.SIGINT)
+ pid = int(f.read())
+ os.kill(pid, signal.SIGINT)
+ if os.name == 'nt':
ukai 2016/10/03 02:52:52 factor out a func to wait for pid?
Vadim Sh. 2016/10/03 19:07:06 +1
tikuta 2016/10/04 03:45:26 Done.
+ os.waitpid(pid, 0)
+ else:
+ while True:
ukai 2016/10/03 02:52:52 might be better to abandon if it tried >5 sec or s
Vadim Sh. 2016/10/03 19:07:06 +1 also nit while is_running_posix(pid): time.
tikuta 2016/10/04 03:45:26 Done.
+ if is_running_posix(pid):
+ time.sleep(1)
+ else:
+ break
if '__main__' == __name__:
sys.exit(main())
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698