Ive been messing with this but keep getting an error, Im assuming the pid is changing right before Im asking for the cpu_percent. Heres my little test program, it basically is opening a file waiting for the the program to finish loading close the program and repeats. After a few loads Ill get the "psutil.NoSuchProcess: psutil.NoSuchProcess process no longer exists (pid=10144)". Any guidance on this would be great.
import psutil
from time import gmtime, strftime
import time
import os
def Monitor():
i = "True"
while i == "True":
process = [proc for proc in psutil.process_iter()]
for object in process:
if 'MSACCESS.EXE' in object.name():
if object.name() == 'MSACCESS.EXE':
a=object.cpu_percent(interval=1)
time.sleep(10)
print(a)
if a > 0:
i = "True"
else:
i = "False"
print("Finished")
repeat = "repeat"
while repeat == "repeat":
os.startfile('\\\\revvedupoffice\\Revved Up\\Collective 10.0.accdb')
Monitor()
os.system("TASKKILL /F /IM MSACCESS.EXE")
time.sleep(10)