What happened / 发生了什么
在 macOS 本地运行 AstrBot 时,如果开启文件日志,进程退出时会稳定出现 Python multiprocessing.resource_tracker 的 semaphore 泄漏提示。
开启一个文件日志 sink 时:
resource_tracker: There appear to be 8 leaked semaphore objects to clean up at shutdown
如果同时开启普通日志和 trace 日志,则数量会变成 16:
resource_tracker: There appear to be 16 leaked semaphore objects to clean up at shutdown
该问题不影响 AstrBot 主功能运行,但会污染退出时的终端输出,也容易让用户误以为插件或平台适配器存在资源泄漏。
Reproduce / 如何复现?
- 在 macOS 本地启动 AstrBot
- 开启文件日志:
{
"log_file_enable": true,
"log_file_path": "logs/astrbot.log"
}
- 启动 AstrBot
- 退出进程
- 观察终端输出
如果同时开启 trace 日志:
{
"log_file_enable": true,
"trace_log_enable": true,
"log_file_path": "logs/astrbot.log",
"trace_log_path": "logs/astrbot.trace.log"
}
退出时 warning 数量会从 8 变成 16。
AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
- AstrBot version: v4.25.2
- Deployment: macOS local source / CLI run
- Provider: not related
- Messaging platform: not related
OS
macOS
Logs / 报错日志
开启一个文件日志 sink 时:
resource_tracker: There appear to be 8 leaked semaphore objects to clean up at shutdown
同时开启普通日志和 trace 日志时:
resource_tracker: There appear to be 16 leaked semaphore objects to clean up at shutdown
预期行为:
AstrBot 正常关闭时应 flush 并移除 Loguru file / trace sinks,不应在退出阶段输出 resource_tracker semaphore warning。
初步判断:
astrbot/core/log.py 中的文件日志 sink 使用了 Loguru 的 enqueue=True:
_loguru.add(..., enqueue=True, ...)
Loguru 在 enqueue=True 时会创建 multiprocessing 队列相关资源。当前这些 sink 在日志重配置时会被移除,但在 AstrBot 进程关闭路径中没有统一清理。
Are you willing to submit a PR? / 你愿意提交 PR 吗?
Code of Conduct
What happened / 发生了什么
在 macOS 本地运行 AstrBot 时,如果开启文件日志,进程退出时会稳定出现 Python
multiprocessing.resource_tracker的 semaphore 泄漏提示。开启一个文件日志 sink 时:
如果同时开启普通日志和 trace 日志,则数量会变成 16:
该问题不影响 AstrBot 主功能运行,但会污染退出时的终端输出,也容易让用户误以为插件或平台适配器存在资源泄漏。
Reproduce / 如何复现?
{ "log_file_enable": true, "log_file_path": "logs/astrbot.log" }如果同时开启 trace 日志:
{ "log_file_enable": true, "trace_log_enable": true, "log_file_path": "logs/astrbot.log", "trace_log_path": "logs/astrbot.trace.log" }退出时 warning 数量会从 8 变成 16。
AstrBot version, deployment method (e.g., Windows Docker Desktop deployment), provider used, and messaging platform used. / AstrBot 版本、部署方式(如 Windows Docker Desktop 部署)、使用的提供商、使用的消息平台适配器
OS
macOS
Logs / 报错日志
开启一个文件日志 sink 时:
同时开启普通日志和 trace 日志时:
预期行为:
AstrBot 正常关闭时应 flush 并移除 Loguru file / trace sinks,不应在退出阶段输出
resource_trackersemaphore warning。初步判断:
astrbot/core/log.py中的文件日志 sink 使用了 Loguru 的enqueue=True:Loguru 在
enqueue=True时会创建 multiprocessing 队列相关资源。当前这些 sink 在日志重配置时会被移除,但在 AstrBot 进程关闭路径中没有统一清理。Are you willing to submit a PR? / 你愿意提交 PR 吗?
Code of Conduct