I would like to get a list of all running Python processes under Windows 7 (and later Linux) at an acceptable time. Based on the results, I would like to start new new Processes on which my main application depends.
I tried psutil from https://github.com/giampaolo/psutil :
import psutil for process in psutil.process_iter(): if process.name == 'python.exe': print(process)
It gave me good results, but launching it took about one minute!
I realized that iterating through all processes with psutil.process_iter () and listing all processes with psutil.get_pid_list () are acceptable quickly, but getting each Process Name to identify Python processes (which I would investigate further using process.cmdline ) seems to be , expensive.
Any idea how to significantly improve speed or another approach?
André source share