fix(backend): 后台任务注册表收编三处无主 create_task - #76
Merged
Merged
Conversation
This was referenced Sep 27, 2026
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.
What & why
修复 #72 / 矩阵 D-9:三处 fire-and-forget
create_task无引用、无异常收集、不受停机管理:scheduler.py启动首次_rescan_sources()/_recover_analysis_jobs_on_startup()—— 异常静默丢失("Task exception was never retrieved"),停机时与engine.dispose()竞争 session;daily_reports.py日报后台_bg_generate——mark_error失败被裸except: pass吞掉,报告可永远卡在 GENERATING。修复:新增
app/core/task_registry.py(兴趣向量重建模式的通用化)——track_background_task保存引用 + done callback 记异常日志;drain_tracked_tasks停机统一 cancel+等待(超时告警不强杀)。三处调用点接入;lifespan 停机在shutdown_scheduler后 drain;日报mark_error失败改为logger.exception留痕。Refs #72(Parent #6)。Closes #72。
Area
Verification
tests/test_task_registry.py:异常记日志并注销 / drain 取消清空 / 超时告警不抛出 / 空注册表 no-oppy_compile+ruff check+ruff format --check全过Verifier verdict
CI 门禁即机器 Verifier;注册表契约由独立单测钉死(含「未启动即 cancel」等 asyncio 边界语义)。
Checklist
issue-<number>-<short-slug>and PR links the issue