Skip to content

Commit

Permalink
[610] Improved process_iter
Browse files Browse the repository at this point in the history
Significant speed-up. Around 20x in psutils 6.0!
  • Loading branch information
Rixxan committed Jul 29, 2024
1 parent 759fc12 commit 1e9dec1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2156,12 +2156,11 @@ def game_running(self) -> bool:
# Process likely expired
self.running_process = None
if not self.running_process:
edmc_process = psutil.Process()
edmc_user = edmc_process.username()
try:
for pid in psutil.pids():
proc = psutil.Process(pid)
if 'EliteDangerous' in proc.name() and proc.username() == edmc_user:
edmc_process = psutil.Process()
edmc_user = edmc_process.username()
for proc in psutil.process_iter(['name', 'username']):
if 'EliteDangerous' in proc.info['name'] and proc.info['username'] == edmc_user:
self.running_process = proc
return True
except psutil.NoSuchProcess:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ simplesystray==0.1.0; sys_platform == 'win32'
semantic-version==2.10.0
# For manipulating folder permissions and the like.
pywin32==306; sys_platform == 'win32'
psutil==5.9.8
psutil==6.0.0

0 comments on commit 1e9dec1

Please sign in to comment.