[Bug] 同步控制台日志在 stdout 受阻时阻塞主事件循环,导致整个 WebUI 无响应
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 22/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- observability-sre
Hướng nghiên cứu
The stall is in the logging path: astrbot/core/log.py (the emit method that forwards stdlib logging records to loguru) and the loguru stream sink it writes to. Start by reading how the stdout sink is configured, then reproduce by blocking stdout on Windows while the WebChat page makes requests. Done would mean logging cannot block the event loop when stdout stalls, for example by making the sink non-blocking or queued, with a test that simulates a slow stream.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
问题描述
在 Windows 本地运行 AstrBot,使用 WebChat 测试期间,整个 Dashboard 出现无响应。刷新页面或打开其他页面均无法恢复。
排查时发现,后端也无法响应独立 HTTP 请求:
GET / → TimeoutError,约 4 秒
GET /api/stat/start-time → TimeoutError,约 4 秒
watchdog 捕获到的主线程栈停在:
logger.info(...)
→ logging.Handler.emit
→ Loguru
→ StreamSink.write
→ self._stream.write(message)
其中一次阻塞发生在插件接口的入口日志处,尚未进入接口主体。
目前确认的是:标准输出写入阻塞会同步阻塞调用日志的主事件循环。 实际运行中 stdout 为何受阻,不知道。
如何复现?
- 在 Windows 本地启动 AstrBot,打开 Dashboard。
- 使用 WebChat 测试,期间出现整个面板无响应。
- 从独立进程请求首页和状态接口,均超时。
- 查看 data/logs/event_loop_watchdog.log,主线程停在 Loguru 的标准输出写入处。
AstrBot 版本
v4.29.3,Python 3.12.14
操作系统
Windows
部署方式
本地源码部署,Python 虚拟环境,通过 PowerShell 启动 python main.py
使用的消息平台适配器
WebChat
错误日志
Event loop stalled for 34.985s
Thread 12084 "MainThread"
...
File ".../astrbot_plugin_meme_manager/mixins/web_api.py",
line 567, in logged_handler
logger.info(f"{WEBUI_LOG_PREFIX} {request.method} {route_path} 开始")
...
File ".../astrbot/core/log.py", line 235, in emit
_loguru.bind(**payload).opt(exception=record.exc_info).log(
File ".../loguru/_logger.py", line 2103, in log
__self._log(__level, False, __self._options, __message, args, kwargs)
File ".../loguru/_logger.py", line 2066, in _log
handler.emit(log_record, level_id, from_decorator, raw, colored_message)
File ".../loguru/_handler.py", line 206, in emit
self._sink.write(str_record)
File ".../loguru/_simple_sinks.py", line 16, in write
self._stream.write(message)
辅助信息
检查清单
- Ngôn ngữ chính
- Python
- Star
- 46.4k
- Fork
- 3.4k
- Merge trung bình
- 1 ngày 11 giờ
- Pull request đã merge (30 ngày)
- 120
Chuẩn bị môi trường
- Có Dockerfile hoặc tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của AstrBotDevs/AstrBot
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
AstrBotDevs/AstrBot#11038 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
AstrBotDevs/AstrBot#11034 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
AstrBotDevs/AstrBot#10999 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] OpenAI-compatible Gemini 工具 schema const 导致 400Có thể đã có người làm @arccat-114 đã nhận 17 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
AstrBotDevs/AstrBot#10720 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] Discord slash command sync aborts with KeyError when a plugin handler is defined in a submoduleCó thể đã có người làm @yuexia5 đã nhận 21 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
AstrBotDevs/AstrBot#10626 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của AstrBotDevs/AstrBot
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bytedance/agentkit-samples#277 ·
-
ai-driven-fuzzing bug claude Minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 83/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Edit: TVS Encarnacion [PY]Đang mởchannels:edit check:passed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[Bug] The blue-green mitigation strategy lists catalog names and views before the source tablesĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws-samples/sample-aws-genai-db-modernizer#2097 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
Maintainer thường phản hồi trong vòng 1 ngày