[testrunner] Properly terminate worker processes on Windows
Bug: v8:8170 Change-Id: I4b4a2919f6cf613779eeabc6c2cec1b08fa4d80f Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1981152 Reviewed-by: Tamer Tas <tmrts@chromium.org> Commit-Queue: Michael Achenbach <machenbach@chromium.org> Cr-Commit-Position: refs/heads/master@{#65626}
This commit is contained in:
parent
31668eb256
commit
92b3a4779f
@ -184,6 +184,22 @@ class PosixCommand(BaseCommand):
|
|||||||
process.kill()
|
process.kill()
|
||||||
|
|
||||||
|
|
||||||
|
def taskkill_windows(process, verbose=False, force=True):
|
||||||
|
force_flag = ' /F' if force else ''
|
||||||
|
tk = subprocess.Popen(
|
||||||
|
'taskkill /T%s /PID %d' % (force_flag, process.pid),
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.PIPE,
|
||||||
|
)
|
||||||
|
stdout, stderr = tk.communicate()
|
||||||
|
if verbose:
|
||||||
|
print('Taskkill results for %d' % process.pid)
|
||||||
|
print(stdout)
|
||||||
|
print(stderr)
|
||||||
|
print('Return code: %d' % tk.returncode)
|
||||||
|
sys.stdout.flush()
|
||||||
|
|
||||||
|
|
||||||
class WindowsCommand(BaseCommand):
|
class WindowsCommand(BaseCommand):
|
||||||
def _start_process(self, **kwargs):
|
def _start_process(self, **kwargs):
|
||||||
# Try to change the error mode to avoid dialogs on fatal errors. Don't
|
# Try to change the error mode to avoid dialogs on fatal errors. Don't
|
||||||
@ -213,18 +229,7 @@ class WindowsCommand(BaseCommand):
|
|||||||
return subprocess.list2cmdline(self._to_args_list())
|
return subprocess.list2cmdline(self._to_args_list())
|
||||||
|
|
||||||
def _kill_process(self, process):
|
def _kill_process(self, process):
|
||||||
tk = subprocess.Popen(
|
taskkill_windows(process, self.verbose)
|
||||||
'taskkill /T /F /PID %d' % process.pid,
|
|
||||||
stdout=subprocess.PIPE,
|
|
||||||
stderr=subprocess.PIPE,
|
|
||||||
)
|
|
||||||
stdout, stderr = tk.communicate()
|
|
||||||
if self.verbose:
|
|
||||||
print('Taskkill results for %d' % process.pid)
|
|
||||||
print(stdout)
|
|
||||||
print(stderr)
|
|
||||||
print('Return code: %d' % tk.returncode)
|
|
||||||
sys.stdout.flush()
|
|
||||||
|
|
||||||
|
|
||||||
class AndroidCommand(BaseCommand):
|
class AndroidCommand(BaseCommand):
|
||||||
|
@ -19,6 +19,7 @@ except ImportError:
|
|||||||
from Queue import Empty # Python 2
|
from Queue import Empty # Python 2
|
||||||
|
|
||||||
from . import command
|
from . import command
|
||||||
|
from . import utils
|
||||||
|
|
||||||
|
|
||||||
def setup_testing():
|
def setup_testing():
|
||||||
@ -243,6 +244,13 @@ class Pool():
|
|||||||
"""
|
"""
|
||||||
self.abort_now = True
|
self.abort_now = True
|
||||||
|
|
||||||
|
def _terminate_processes(self):
|
||||||
|
for p in self.processes:
|
||||||
|
if utils.IsWindows():
|
||||||
|
command.taskkill_windows(p, verbose=True, force=False)
|
||||||
|
else:
|
||||||
|
os.kill(p.pid, signal.SIGTERM)
|
||||||
|
|
||||||
def _terminate(self):
|
def _terminate(self):
|
||||||
"""Terminates execution and cleans up the queues.
|
"""Terminates execution and cleans up the queues.
|
||||||
|
|
||||||
@ -267,8 +275,7 @@ class Pool():
|
|||||||
self.work_queue.put("STOP")
|
self.work_queue.put("STOP")
|
||||||
|
|
||||||
if self.abort_now:
|
if self.abort_now:
|
||||||
for p in self.processes:
|
self._terminate_processes()
|
||||||
os.kill(p.pid, signal.SIGTERM)
|
|
||||||
|
|
||||||
self.notify("Joining workers")
|
self.notify("Joining workers")
|
||||||
for p in self.processes:
|
for p in self.processes:
|
||||||
|
Loading…
Reference in New Issue
Block a user