| OLD | NEW |
| 1 # Copyright (c) 2009, Google Inc. All rights reserved. | 1 # Copyright (c) 2009, Google Inc. All rights reserved. |
| 2 # Copyright (c) 2009 Apple Inc. All rights reserved. | 2 # Copyright (c) 2009 Apple Inc. All rights reserved. |
| 3 # | 3 # |
| 4 # Redistribution and use in source and binary forms, with or without | 4 # Redistribution and use in source and binary forms, with or without |
| 5 # modification, are permitted provided that the following conditions are | 5 # modification, are permitted provided that the following conditions are |
| 6 # met: | 6 # met: |
| 7 # | 7 # |
| 8 # * Redistributions of source code must retain the above copyright | 8 # * Redistributions of source code must retain the above copyright |
| 9 # notice, this list of conditions and the following disclaimer. | 9 # notice, this list of conditions and the following disclaimer. |
| 10 # * Redistributions in binary form must reproduce the above | 10 # * Redistributions in binary form must reproduce the above |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 139 |
| 140 # According to http://docs.python.org/library/os.html | 140 # According to http://docs.python.org/library/os.html |
| 141 # os.kill isn't available on Windows. python 2.5.5 os.kill appears | 141 # os.kill isn't available on Windows. python 2.5.5 os.kill appears |
| 142 # to work in cygwin, however it occasionally raises EAGAIN. | 142 # to work in cygwin, however it occasionally raises EAGAIN. |
| 143 retries_left = 10 if sys.platform == "cygwin" else 1 | 143 retries_left = 10 if sys.platform == "cygwin" else 1 |
| 144 while retries_left > 0: | 144 while retries_left > 0: |
| 145 try: | 145 try: |
| 146 retries_left -= 1 | 146 retries_left -= 1 |
| 147 os.kill(pid, signal.SIGKILL) | 147 os.kill(pid, signal.SIGKILL) |
| 148 _ = os.waitpid(pid, os.WNOHANG) | 148 _ = os.waitpid(pid, os.WNOHANG) |
| 149 except OSError as e: | 149 except OSError as error: |
| 150 if e.errno == errno.EAGAIN: | 150 if error.errno == errno.EAGAIN: |
| 151 if retries_left <= 0: | 151 if retries_left <= 0: |
| 152 _log.warning("Failed to kill pid %s. Too many EAGAIN er
rors.", pid) | 152 _log.warning("Failed to kill pid %s. Too many EAGAIN er
rors.", pid) |
| 153 continue | 153 continue |
| 154 if e.errno == errno.ESRCH: # The process does not exist. | 154 if error.errno == errno.ESRCH: # The process does not exist. |
| 155 return | 155 return |
| 156 if e.errno == errno.EPIPE: # The process has exited already on
cygwin | 156 if error.errno == errno.EPIPE: # The process has exited already
on cygwin |
| 157 return | 157 return |
| 158 if e.errno == errno.ECHILD: | 158 if error.errno == errno.ECHILD: |
| 159 # Can't wait on a non-child process, but the kill worked. | 159 # Can't wait on a non-child process, but the kill worked. |
| 160 return | 160 return |
| 161 if e.errno == errno.EACCES and sys.platform == 'cygwin': | 161 if error.errno == errno.EACCES and sys.platform == 'cygwin': |
| 162 # Cygwin python sometimes can't kill native processes. | 162 # Cygwin python sometimes can't kill native processes. |
| 163 return | 163 return |
| 164 raise | 164 raise |
| 165 | 165 |
| 166 def _win32_check_running_pid(self, pid): | 166 def _win32_check_running_pid(self, pid): |
| 167 # importing ctypes at the top-level seems to cause weird crashes at | 167 # importing ctypes at the top-level seems to cause weird crashes at |
| 168 # exit under cygwin on apple's win port. Only win32 needs cygwin, so | 168 # exit under cygwin on apple's win port. Only win32 needs cygwin, so |
| 169 # we import it here instead. See https://bugs.webkit.org/show_bug.cgi?id
=91682 | 169 # we import it here instead. See https://bugs.webkit.org/show_bug.cgi?id
=91682 |
| 170 import ctypes | 170 import ctypes |
| 171 | 171 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 pool.close() | 470 pool.close() |
| 471 pool.join() | 471 pool.join() |
| 472 | 472 |
| 473 | 473 |
| 474 def _run_command_thunk(cmd_line_and_cwd): | 474 def _run_command_thunk(cmd_line_and_cwd): |
| 475 # Note that this needs to be a bare module (and hence Picklable) method to w
ork with multiprocessing.Pool. | 475 # Note that this needs to be a bare module (and hence Picklable) method to w
ork with multiprocessing.Pool. |
| 476 (cmd_line, cwd) = cmd_line_and_cwd | 476 (cmd_line, cwd) = cmd_line_and_cwd |
| 477 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su
bprocess.PIPE) | 477 proc = subprocess.Popen(cmd_line, cwd=cwd, stdout=subprocess.PIPE, stderr=su
bprocess.PIPE) |
| 478 stdout, stderr = proc.communicate() | 478 stdout, stderr = proc.communicate() |
| 479 return (proc.returncode, stdout, stderr) | 479 return (proc.returncode, stdout, stderr) |
| OLD | NEW |