auto-sync: 2026-05-26 08:32:08
This commit is contained in:
+17
-2
@@ -875,17 +875,32 @@ class Ticker:
|
||||
except (ValueError, TypeError):
|
||||
pass
|
||||
|
||||
# v2.7.2: 进程存活性检查 — counter 占用但进程已死的光底
|
||||
# v2.7.2: 进程存活性检查 — counter 占用但进程已死的兜底
|
||||
if self.spawner and self.counter:
|
||||
for agent_id in list(self.counter.active_agents.keys()):
|
||||
session_info = self.spawner.get_session_by_agent(agent_id)
|
||||
if not session_info:
|
||||
continue
|
||||
pid = session_info.get("pid")
|
||||
task_id_check = session_info.get("task_id")
|
||||
if pid and not self._is_pid_alive(pid):
|
||||
logger.warning("Agent %s process dead (pid=%d), releasing counter",
|
||||
logger.warning("Agent %s process dead (pid=%d), releasing counter + push back pending",
|
||||
agent_id, pid)
|
||||
self.counter.release(agent_id)
|
||||
# 推回 pending 让 ticker 重新 dispatch
|
||||
if task_id_check and db_path:
|
||||
try:
|
||||
conn = get_connection(db_path)
|
||||
try:
|
||||
self._transition_status(
|
||||
conn, task_id_check, "pending",
|
||||
agent="daemon",
|
||||
detail={"reason": "process_dead", "pid": pid},
|
||||
)
|
||||
finally:
|
||||
conn.close()
|
||||
except Exception:
|
||||
logger.exception("Failed to push back task %s", task_id_check)
|
||||
|
||||
return reclaimed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user