Conversation
…esquena#1312) _run_cron_tracked() runs inside a worker thread (threading.Thread), so it cannot see the caller's local import of run_job from _handle_cron_run. Moved the import into _run_cron_tracked and removed the now-redundant import from the route handler. Fixes nesquena#1312, Fixes nesquena#1310
|
Thanks for the fix and especially for the regression tests — the AST-based check that ConfirmationDiagnosis is correct, and matches what's in master:
Result: Overlap with #1312This PR overlaps with the existing #1312 (same one-line import fix, same hunk). The substantive differences in your PR:
A small test-code note (non-blocking)In ImportCollector = type(
"ImportCollector",
(ast.NodeVisitor,),
{
"imports": set(),
"visit_ImportFrom": lambda self, node: (
self.imports.add(a.name for a in node.names),
),
},
)This class is constructed but never instantiated or visited — the actual import collection happens in the loop below. You can drop the entire RecommendationEither of #1312 or #1317 fixes the runtime bug. This PR is the more complete one (cleanup + tests). I'd suggest:
Maintainer will pick. Thanks for the careful work — the regression tests in particular are valuable. 🤖 Automated triage via nesquena-hermes |
|
Shipped in v0.50.245 via batch release PR #1334 (merge commit Live now at https://github.com/nesquena/hermes-webui/releases/tag/v0.50.245. Released alongside 9 other contributor fixes — see the v0.50.245 entry in CHANGELOG.md. |
…esquena#1310) From PR nesquena#1317. Co-authored-by: fxd-jason <wujiachen7@gmail.com>
…esquena#1310) From PR nesquena#1317. Co-authored-by: fxd-jason <wujiachen7@gmail.com>
…esquena#1310) From PR nesquena#1317. Co-authored-by: fxd-jason <wujiachen7@gmail.com>
Problem
_run_cron_tracked()runs inside a worker thread (threading.Thread) atapi/routes.py. It calledrun_job(job)butrun_jobwas only imported as a local variable inside_handle_cron_run()— a completely separate function scope. When the thread executed,run_jobwas not in scope →NameError.This caused "Run Now" in the cron panel to crash every time.
Fix
Moved
from cron.scheduler import run_jobinto_run_cron_tracked()itself so the import resolves in the worker thread's scope. Removed the now-redundant import from_handle_cron_run().Files changed:
api/routes.py— moved import into_run_cron_tracked, removed from_handle_cron_runtests/test_cron_run_job_import.py— 3 AST-based regression testsTesting