fix: 修复内存泄漏和僵尸进程问题

- 添加SIGCHLD信号处理器自动回收僵尸子进程
- 定期清理函数增加僵尸进程回收
- 增加batch_task_screenshots超时清理(30分钟)
- 增加pending_random_schedules超时清理(2小时)
- 修复playwright_automation.py的_force_cleanup使用SIGTERM+waitpid
- browser_installer.py浏览器检测后添加僵尸进程清理

内存占用从111MB降至53MB,僵尸进程从6个降至0个
This commit is contained in:
Yu Yon
2025-12-12 23:42:30 +08:00
parent 352c61fbd4
commit b905739515
3 changed files with 81 additions and 1 deletions

View File

@@ -1438,7 +1438,7 @@ class PlaywrightAutomation:
try:
import os
import signal
os.kill(browser_pid, signal.SIGKILL)
os.kill(browser_pid, signal.SIGTERM); import time; time.sleep(0.5); os.waitpid(browser_pid, os.WNOHANG)
except (ProcessLookupError, PermissionError, OSError):
pass # 进程可能已经退出