From ef57c631e696b4054099fd7bff90afffc5814490 Mon Sep 17 00:00:00 2001 From: John Haddon Date: Wed, 6 Dec 2023 11:24:57 +0000 Subject: [PATCH] Stats app : Replace Windows subprocess with `psutil` --- apps/stats/stats-1.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/apps/stats/stats-1.py b/apps/stats/stats-1.py index 0a2fa417476..24c2101cc6f 100644 --- a/apps/stats/stats-1.py +++ b/apps/stats/stats-1.py @@ -45,7 +45,7 @@ if sys.platform != "win32": import resource else: - import subprocess + import psutil import IECore @@ -746,8 +746,7 @@ def maxRSS( cls ) : if sys.platform == "darwin" : return cls( resource.getrusage( resource.RUSAGE_SELF ).ru_maxrss ) elif sys.platform == "win32" : - result = subprocess.check_output( ["wmic", "process", "where", "processid={}".format(os.getpid()), "get", "PeakWorkingSetSize"] ) - return cls( int( result.split()[1] ) * 1024 ) + return cls( psutil.Process().memory_info().peak_wset ) else : return cls( resource.getrusage( resource.RUSAGE_SELF ).ru_maxrss * 1024 )