Testing - Replace Linux only 'resource' library with cross-platform 'psutil' library (#3037)

This commit is contained in:
Nico Ell
2025-03-21 09:50:32 +01:00
committed by GitHub
parent 73189672c3
commit 70a18ee4b5
2 changed files with 6 additions and 5 deletions

View File

@@ -1,5 +1,5 @@
#!/usr/bin/env python3
import resource
import psutil
import time
from threading import Thread
@@ -28,9 +28,10 @@ def reportlog(pytestconfig):
def track_memory(memory_usage, ):
process = psutil.Process(os.getpid())
while not memory_usage["stop"]:
max_rss = resource.getrusage(resource.RUSAGE_SELF).ru_maxrss
memory_usage["peak"] = max(memory_usage["peak"], max_rss)
current_rss = process.memory_info().rss
memory_usage["peak"] = max(memory_usage["peak"], current_rss)
time.sleep(0.01) # Adjust the sleep time as needed
@pytest.fixture(scope='function')

View File

@@ -110,5 +110,5 @@ tzdata
pluggy ~= 1.5
# Needed for testing, cross-platform for process and system monitoring
psutil==7.0.0