Skip to content

fix: improve terminal log diagnostics and HTTP timeout handling - #1712

Merged
SAKURA-CAT merged 3 commits into
SwanHubX:mainfrom
scpoppin1207:main
Jul 24, 2026
Merged

fix: improve terminal log diagnostics and HTTP timeout handling#1712
SAKURA-CAT merged 3 commits into
SwanHubX:mainfrom
scpoppin1207:main

Conversation

@scpoppin1207

@scpoppin1207 scpoppin1207 commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • 完善终端日志从捕获、缓冲、落盘、入队、分发到 HTTP 请求的全链路调试信息,便于定位日志上传问题。
  • 修复 Requests 显式传入 timeout=None 时,TimeoutHTTPAdapter 配置的默认超时未生效的问题。
  • 移除数据存储逐条写入后的即时 flush,降低高频磁盘 I/O 对上传效率的影响。

Changes

  • TerminalProxyBackgroundConsumerCorePythonDispatchHttpRecordSender 的关键阶段增加 debug 日志,记录批次数量和 record 编号范围,且不写入 TTY。
  • 当请求未传超时或显式传入 timeout=None 时,由 TimeoutHTTPAdapter 注入配置的默认超时。
  • DataStoreWriter.write() 不再每次写入后立即 flush,仍由 ensure_flushed()close() 执行显式刷新。
  • 增加默认超时覆盖场景的回归测试。

Testing

  • uv run pytest tests/unit/sdk/internal/pkg/client/test_client_session.py:12 passed
  • 对涉及文件运行 uv run ruff check:All checks passed

Notes

  • 新增日志均为 debug 级别,不会写入用户终端。
  • 数据写入的刷新时机有所调整,关闭存储或显式调用 ensure_flushed() 时仍会刷新缓冲区。

@SAKURA-CAT SAKURA-CAT added the 🐛 bug Something isn't working label Jul 24, 2026
@SAKURA-CAT SAKURA-CAT self-assigned this Jul 24, 2026
@SAKURA-CAT SAKURA-CAT changed the title Update test_client_session.py fix: improve terminal log diagnostics and HTTP timeout handling Jul 24, 2026
High-frequency flush/fsync on every write causes excessive disk I/O and
can
block the writer thread on network file systems like NAS. Flushing is
now
deferred to close(), with a small risk of losing buffered data on
abnormal
exit. A future Go rewrite will decouple local persistence from remote
upload.
@Nexisato

Copy link
Copy Markdown
Collaborator

最大风险就是训练进程 crash 后,尾部的 buffer 数据未持久化也未上报,这一部分指标数据会丢失,但既然 crash 的话这个抖动结果应该是可接受的

@Nexisato

Copy link
Copy Markdown
Collaborator

TODO 一下 cloud-only 模式,NAS 的高频 IO 是挺难受,不过无法做持久化,crash 即丢点

@SAKURA-CAT
SAKURA-CAT merged commit 6665222 into SwanHubX:main Jul 24, 2026
19 checks passed
@SAKURA-CAT SAKURA-CAT mentioned this pull request Jul 24, 2026
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants