5

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)
scate636
  • 135
  • 2
  • 11
  • What version of psutil and Windows are you running on? I have a similar issue using 3.4.2. Our app has to support XP machines for the time being so I compile my app using pyinstaller on XP (lowest common denominator). I have found some other similar issues by searching for this error with Google and have found some evidence updating to newer versions of psutil will fix this. If you could post what version your using, that would assist me also. – Sherd Aug 27 '19 at 17:06

0 Answers0