Skip to content
This repository was archived by the owner on Jan 9, 2026. It is now read-only.

Commit 87ecaa4

Browse files
committed
chore: bump version to 1.2.1
- Update version from 1.2.0 to 1.2.1 in __version__.py - Enhance _get_process_resources() to return process running status as third value - Add process.is_running() check to detect terminated processes accurately - Refactor process resource monitoring logic to use running status flag instead of checking if cpu/mem > 0 - Simplify PMHQ and LLBot running state detection by using returned is_running value - Improve reliability of process status detection for manager, PMHQ, and LLBot processes
1 parent 2e27d73 commit 87ecaa4

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
"""应用版本信息"""
22

3-
__version__ = "1.2.0"
3+
__version__ = "1.2.1"

ui/home_page.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2057,15 +2057,17 @@ def _get_process_resources(self, pid: int) -> tuple:
20572057
"""获取进程的 CPU 和内存使用情况
20582058
20592059
Returns:
2060-
(cpu_percent, memory_mb) 或 (0.0, 0.0) 如果获取失败
2060+
(cpu_percent, memory_mb, is_running) 或 (0.0, 0.0, False) 如果进程不存在
20612061
"""
20622062
try:
20632063
proc = psutil.Process(pid)
2064+
if not proc.is_running():
2065+
return 0.0, 0.0, False
20642066
cpu = proc.cpu_percent(interval=0.05)
20652067
mem = proc.memory_info().rss / 1024 / 1024
2066-
return cpu, mem
2068+
return cpu, mem, True
20672069
except (psutil.NoSuchProcess, psutil.AccessDenied):
2068-
return 0.0, 0.0
2070+
return 0.0, 0.0, False
20692071

20702072
def refresh_process_resources(self):
20712073
import logging
@@ -2077,7 +2079,7 @@ def refresh_process_resources(self):
20772079

20782080
# 管理器自身
20792081
manager_pid = os.getpid()
2080-
cpu, mem = self._get_process_resources(manager_pid)
2082+
cpu, mem, _ = self._get_process_resources(manager_pid)
20812083
total_cpu += cpu
20822084
total_mem += mem
20832085
logger.debug(f"管理器 - PID: {manager_pid}, CPU: {cpu:.1f}%, 内存: {mem:.1f}MB")
@@ -2088,22 +2090,20 @@ def refresh_process_resources(self):
20882090
pmhq_pid = pids.get("pmhq")
20892091
pmhq_running = False
20902092
if pmhq_pid:
2091-
cpu, mem = self._get_process_resources(pmhq_pid)
2092-
if cpu > 0 or mem > 0:
2093+
cpu, mem, pmhq_running = self._get_process_resources(pmhq_pid)
2094+
if pmhq_running:
20932095
total_cpu += cpu
20942096
total_mem += mem
2095-
pmhq_running = True
20962097
logger.debug(f"PMHQ - PID: {pmhq_pid}, CPU: {cpu:.1f}%, 内存: {mem:.1f}MB")
20972098

20982099
# LLBot
20992100
llbot_pid = pids.get("llbot")
21002101
llbot_running = False
21012102
if llbot_pid:
2102-
cpu, mem = self._get_process_resources(llbot_pid)
2103-
if cpu > 0 or mem > 0:
2103+
cpu, mem, llbot_running = self._get_process_resources(llbot_pid)
2104+
if llbot_running:
21042105
total_cpu += cpu
21052106
total_mem += mem
2106-
llbot_running = True
21072107
logger.debug(f"LLBot - PID: {llbot_pid}, CPU: {cpu:.1f}%, 内存: {mem:.1f}MB")
21082108

21092109
# Bot运行状态:PMHQ和LLBot都启动才算运行中

0 commit comments

Comments
 (0)