mirror of
https://github.com/ZhuLinsen/daily_stock_analysis
synced 2026-09-20 10:53:33 +08:00
fix(issue-1853): [bug]-在网页端点击“立即执行一次”后后台线程因缺少-`stock_code (#1854)
This commit is contained in:
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
||||
- [新功能] 报告输出语言新增韩语(`REPORT_LANGUAGE=ko`),覆盖个股报告、大盘复盘、提示词输出语言、决策护栏、通知模板标签与 Web 报告详情页文案;`ko` 复用英文结构骨架并约束模型用韩文输出,`zh`/`en` 行为保持不变 (#1614)
|
||||
|
||||
- [修复] 修复 Web 首页个股栏在 stock-bar 摘要字段缺失或动作建议无法归类时隐藏情绪分与建议标识的问题。
|
||||
- [修复] 修复 Web 设置页定时任务“立即执行一次”后台线程未传 `stock_codes` 导致任务崩溃的问题。
|
||||
|
||||
## [3.24.1] - 2026-06-28
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ class RuntimeSchedulerService:
|
||||
|
||||
def run_and_release() -> None:
|
||||
try:
|
||||
self._run_analysis_locked()
|
||||
self._run_analysis_locked(None)
|
||||
finally:
|
||||
self._run_lock.release()
|
||||
|
||||
|
||||
@@ -80,6 +80,12 @@ class _NoopThread:
|
||||
return False
|
||||
|
||||
|
||||
class _SynchronousThread(_NoopThread):
|
||||
def start(self):
|
||||
if self.target is not None:
|
||||
self.target()
|
||||
|
||||
|
||||
class RuntimeSchedulerServiceTestCase(unittest.TestCase):
|
||||
def test_run_analysis_args_include_workers(self) -> None:
|
||||
config = SimpleNamespace(
|
||||
@@ -182,6 +188,38 @@ class RuntimeSchedulerServiceTestCase(unittest.TestCase):
|
||||
self.assertEqual(status["last_skip_reason"], "analysis_already_running")
|
||||
self.assertIsNotNone(status["last_skipped_at"])
|
||||
|
||||
def test_run_now_runs_analysis_with_default_stock_scope(self) -> None:
|
||||
config = SimpleNamespace(
|
||||
schedule_enabled=True,
|
||||
schedule_time="18:00",
|
||||
schedule_times=["18:00"],
|
||||
)
|
||||
seen_stock_codes = []
|
||||
|
||||
def runner(config_arg, args, stock_codes):
|
||||
seen_stock_codes.append(stock_codes)
|
||||
return True
|
||||
|
||||
service = RuntimeSchedulerService(
|
||||
config_provider=lambda: config,
|
||||
task_runner=runner,
|
||||
)
|
||||
service._reload_config = lambda: config
|
||||
|
||||
with patch(
|
||||
"src.services.runtime_scheduler.threading.Thread",
|
||||
_SynchronousThread,
|
||||
):
|
||||
result = service.run_now()
|
||||
|
||||
self.assertTrue(result["accepted"])
|
||||
self.assertEqual(seen_stock_codes, [None])
|
||||
status = service.status()
|
||||
self.assertFalse(status["running"])
|
||||
self.assertIsNotNone(status["last_run_at"])
|
||||
self.assertIsNotNone(status["last_success_at"])
|
||||
self.assertIsNone(status["last_error"])
|
||||
|
||||
def test_run_now_uses_shared_lock_across_service_instances(self) -> None:
|
||||
config = SimpleNamespace(
|
||||
schedule_enabled=True,
|
||||
|
||||
Reference in New Issue
Block a user