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

Side by Side Diff: scripts/slave/recipe_modules/goma/resources/cloudtail_utils.py

Issue 2440803004: Log when 'cloudtail_utils.py stop' can't find cloudtail PID. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2016 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2016 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import errno 7 import errno
8 import os 8 import os
9 import signal 9 import signal
10 import subprocess 10 import subprocess
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 """Send SIGINT to pid and wait termination of pid. 58 """Send SIGINT to pid and wait termination of pid.
59 59
60 Args: 60 Args:
61 pid(int): pid of process which this function waits termination. 61 pid(int): pid of process which this function waits termination.
62 62
63 Raises: 63 Raises:
64 OSError: is_running_posix, os.waitpid and os.kill may throw OSError. 64 OSError: is_running_posix, os.waitpid and os.kill may throw OSError.
65 NotDiedError: if cloudtail is running after 10 seconds waiting, 65 NotDiedError: if cloudtail is running after 10 seconds waiting,
66 NotDiedError is raised. 66 NotDiedError is raised.
67 """ 67 """
68
68 try: 69 try:
69 os.kill(pid, signal.SIGINT) 70 os.kill(pid, signal.SIGINT)
70 except OSError as e: 71 except OSError as e:
71 # Already dead? 72 # Already dead?
72 if e.errno in (errno.ECHILD, errno.EPERM, errno.ESRCH): 73 if e.errno in (errno.ECHILD, errno.EPERM, errno.ESRCH):
74 print('Can\'t send SIGINT to process %d. Already dead? Errno %d.' %
75 (pid, e.errno))
73 return 76 return
74 raise 77 raise
75 78
76 print('SIGINT has been sent to process %d. ' 79 print('SIGINT has been sent to process %d. '
77 'Going to wait for the process finishes.' % pid) 80 'Going to wait for the process finishes.' % pid)
78 if os.name == 'nt': 81 if os.name == 'nt':
79 try: 82 try:
80 os.waitpid(pid, 0) 83 os.waitpid(pid, 0)
81 except OSError as e: 84 except OSError as e:
82 if e.errno == errno.ECHILD: 85 if e.errno == errno.ECHILD:
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 try: 133 try:
131 os.kill(pid, signal.SIGTERM) 134 os.kill(pid, signal.SIGTERM)
132 except OSError as e: 135 except OSError as e:
133 print('Failed to send SIGTERM to process %d: %s' % (pid, e)) 136 print('Failed to send SIGTERM to process %d: %s' % (pid, e))
134 # We do not reraise because I believe not suspending the process 137 # We do not reraise because I believe not suspending the process
135 # is more important than completely killing cloudtail. 138 # is more important than completely killing cloudtail.
136 139
137 140
138 if '__main__' == __name__: 141 if '__main__' == __name__:
139 sys.exit(main()) 142 sys.exit(main())
OLDNEW
« 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