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

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

Issue 2375843005: Stop redirect stdout/stderr and remove close_fds=True (Closed)
Patch Set: add comment Created 4 years, 3 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
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 ea3c619976c857f27e66c2cefcae7b6e454e78dc..79f20dc1edd7c1ee81c9d20086e9b363e61c5bb5 100644
--- a/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py
+++ b/scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py
@@ -20,13 +20,9 @@ def start_cloudtail(args):
'tail',
'--log-id', 'goma_compiler_proxy',
'--path',
- goma_utils.GetLatestGomaCompilerProxyInfo()],
- stdout=open(os.devnull, 'w'),
- stderr=open(os.devnull, 'w'),
- close_fds=True)
-
- sys.stdout.write(str(proc.pid))
-
+ goma_utils.GetLatestGomaCompilerProxyInfo()])
+ with open(args.pid_file, 'w') as f:
+ f.write(str(proc.pid))
def main():
parser = argparse.ArgumentParser(
@@ -39,25 +35,24 @@ def main():
parser_start.set_defaults(command='start')
parser_start.add_argument('--cloudtail-path', required=True,
help='path of cloudtail binary')
+ parser_start.add_argument('--pid-file', required=True,
+ help='file written pid')
parser_stop = subparsers.add_parser('stop',
help='subcommand to stop cloudtail')
parser_stop.set_defaults(command='stop')
- parser_stop.add_argument('--killed-pid', type=int, required=True,
- help='pid that is killed.')
+ parser_stop.add_argument('--killed-pid-file', required=True,
+ help='file written the pid to be killed.')
args = parser.parse_args()
if args.command == 'start':
start_cloudtail(args)
elif args.command == 'stop':
- try:
- os.kill(args.killed_pid, signal.SIGKILL)
- except OSError as e:
- if e.errno != errno.ESRCH:
- # TODO(tikuta): Resolve https://crbug.com/639910.
- raise
-
+ 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)
Vadim Sh. 2016/09/30 19:04:12 There can potentially be file locking problems on
if '__main__' == __name__:
sys.exit(main())

Powered by Google App Engine
This is Rietveld 408576698