A partially written live command result aborts polling with JSONDecodeError

未关闭 适合新手
#784 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

@pcbeingused333 已经在做这个了。

开始于 2026年11月26日。

  • #788 来自 @pcbeingused333 —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
72/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
docker, python
领域
cli

调研方向

从 lean/components/docker/docker_manager.py 中的 read_from_file 开始:把 json.loads(output) 移到轮询循环内部,使不完整的 payload 会被重试而不是中止,同时完整结果仍会在第一次读取时返回。先按照 issue 的复现,用被 mock 的 subprocess 先返回 b'{"Success":' 再返回完整 JSON 来复现,并检查 docker manager 现有测试中用于轮询 helper 的测试以便扩展。完成意味着不完整读取的情况会在超时内返回之后得到的完整结果,并且在窗口过期后仍能干净地失败;Lean 侧的 producer Common/Commands/FileCommandHandler.cs 只是上下文,不是这里要修改的文件。

由索引模型根据 Issue 内容生成。

描述

priority:P2

Problem

DockerManager.read_from_file stops polling on any nonempty output and only parses JSON afterward. Lean's FileCommandHandler.Acknowledge writes result files using File.WriteAllText, so a read overlapping that write can observe a nonempty prefix and abort with JSONDecodeError, even if the full successful result becomes available within the timeout.

Reproduction

On current master, mock a running container and a subprocess whose stdout.read() returns b'{"Success":'. Call read_from_file('container', Path('result.json'), interval=0.01, timeout=0.1).

Observed: JSONDecodeError: Expecting value: line 1 column 12 (char 11) after the first read, instead of retrying. Returning complete JSON on the next attempt cannot help because the polling loop has already ended.

Relevant code: lean/components/docker/docker_manager.py, the nonempty-output check and subsequent loads(output) in read_from_file; producer: Common/Commands/FileCommandHandler.cs in Lean.

Required result

A result observed during an incomplete write must not abort a command that completes within its wait window. Preserve immediate handling of a complete result and bound retries for an incomplete result. Suggestion: parse inside the polling loop and retry incomplete JSON, or make the producer publish complete files atomically.

主要语言
Python
星标
335
派生
172
平均合并
6 小时 54 分钟
30 天内合并 PR
37

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

QuantConnect/lean-cli 的其他 Issue

查看 QuantConnect/lean-cli 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。