35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
#
|
|
# Created by Technology Group
|
|
#
|
|
# (c) Copyright, Ubisoft Entertainment Inc.
|
|
# ALL RIGHTS RESERVED
|
|
#
|
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
|
|
|
import psutil
|
|
|
|
|
|
# If the tests fail, some of stadia processes are never killed. In this case the pipeline will be stuck until
|
|
# the processes will be killed manually.
|
|
# This function is used to kill all stadia processes that are running after each stack of tests are executed
|
|
def cleanup_stadia_processes():
|
|
stadia_processes_processes = []
|
|
for proc in psutil.process_iter(['pid', 'name', 'username']):
|
|
if proc.info['name'] == 'chrome_client.exe' or proc.info['name'] == 'stadia_process_manager.exe':
|
|
stadia_processes_processes.append(proc)
|
|
try:
|
|
stadia_processes_processes.extend(proc.children(recursive=True))
|
|
except psutil.NoSuchProcess:
|
|
pass
|
|
for process in stadia_processes_processes:
|
|
try:
|
|
process.terminate()
|
|
except psutil.NoSuchProcess:
|
|
pass
|
|
# Give time to for the processes to exit
|
|
_, stadia_processes_processes_still_alive = psutil.wait_procs(stadia_processes_processes, timeout=2)
|
|
for process in stadia_processes_processes_still_alive:
|
|
try:
|
|
process.kill()
|
|
except psutil.NoSuchProcess:
|
|
pass
|