mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2026-11-01 10:22:08 +00:00
fix(monitor): stop intel_gpu_top leaving a process on every GPU reading
This commit is contained in:
@@ -7998,7 +7998,8 @@ def get_detailed_gpu_info(gpu):
|
||||
env = os.environ.copy()
|
||||
env['TERM'] = 'xterm' # Ensure terminal type is set
|
||||
|
||||
cmd = f'{intel_gpu_top_path} -J' # Use the found path
|
||||
# Without a shell: the signal has to reach intel_gpu_top itself.
|
||||
cmd = [intel_gpu_top_path, '-J']
|
||||
# print(f"[v0] Executing command: {cmd}", flush=True)
|
||||
pass
|
||||
|
||||
@@ -8008,7 +8009,6 @@ def get_detailed_gpu_info(gpu):
|
||||
stderr=subprocess.PIPE,
|
||||
text=True,
|
||||
bufsize=1,
|
||||
shell=True,
|
||||
env=env,
|
||||
cwd='/' # Ejecutar desde root en lugar de dentro del AppImage
|
||||
)
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
"""intel_gpu_top runs until it is told to stop, so the Monitor has to hold the
|
||||
process itself: with a shell in between the signal never reaches it."""
|
||||
import ast
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
SOURCE = Path(__file__).resolve().parents[1] / 'flask_server.py'
|
||||
|
||||
|
||||
class IntelGpuTopProcess(unittest.TestCase):
|
||||
def setUp(self):
|
||||
tree = ast.parse(SOURCE.read_text(encoding='utf-8'))
|
||||
self.function = next(node for node in ast.walk(tree) if isinstance(node, ast.FunctionDef)
|
||||
and node.name == 'get_detailed_gpu_info')
|
||||
|
||||
def test_no_process_of_the_gpu_sampling_goes_through_a_shell(self):
|
||||
calls = [node for node in ast.walk(self.function) if isinstance(node, ast.Call)
|
||||
and isinstance(node.func, ast.Attribute) and node.func.attr == 'Popen']
|
||||
self.assertTrue(calls)
|
||||
for call in calls:
|
||||
self.assertNotIn('shell', [keyword.arg for keyword in call.keywords])
|
||||
|
||||
def test_the_command_is_a_list(self):
|
||||
assigned = [node.value for node in ast.walk(self.function) if isinstance(node, ast.Assign)
|
||||
and any(isinstance(target, ast.Name) and target.id == 'cmd' for target in node.targets)]
|
||||
self.assertTrue(assigned)
|
||||
self.assertFalse([value for value in assigned if isinstance(value, ast.JoinedStr)])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user