Repository navigation
fix(code_run): 用 reader join 替代固定 sleep(1) 轮询,省掉每次工具调用最多 1 秒白等 - #876
Closed
leonsong09 wants to merge 1 commit into
Closed
leonsong09 wants to merge 1 commit into
leonsong09 wants to merge 1 commit into
Conversation
进程结束后最长仍要空等 1s 才发现。改为 t.join(0.05) 后一退出即返回。 本机 5.2k 次响应间隔统计中位恰为 1.000s(2012 次精确 1s, code_run 占 1912), 实测短任务 1.01s->0.24s, 3000 行输出 1.01s->0.37s, 退出码与超时行为不变。 补 process.wait() 兜底: reader 可能先于进程回收退出导致 poll() 为 None。
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #875
改动
ga.pycode_run():1 行改 3 行加,净 +3 行。
为什么要加
process.wait()单改
t.join(0.05)会引入回归:reader 线程退出不代表进程已被回收,poll()此时仍返回None,退出码会丢成None(结果被判为⏳而不是success/error)。自测第一版就是这么挂的,所以补 5s 兜底wait();超时仍走poll(),不会卡住。验证(纯内存,old/new 同源对照)
print('hi')sys.exit(7)stop_signal触发[Stopped][Stopped](一致)3000 行输出的内容与顺序逐行比对一致。
收益
temp/model_responses/*.txt的 5,187 个响应间隔中位恰为 1.000s,其中 2,012 次精确 1s,code_run占 1,912 次。短工具调用每次约省 0.77s。影响面
只动
code_run的等待方式,stream_reader、smart_format、超时判定、返回结构均未变。不涉及llmcore/ 前端 / 渠道配置。