fix: 手动运行启动后立即显示运行中状态

- Runner.start 在返回前先拿锁并创建运行记录,后台线程只负责执行
- 修复刚点运行时状态接口短暂显示空闲、紧接着的查询拿到上一条记录的问题
This commit is contained in:
2026-11-06 17:45:05 +08:00
parent 96dd78baca
commit b487a54b94
2 changed files with 23 additions and 7 deletions
+2
View File
@@ -199,6 +199,8 @@ class RunnerTest(unittest.TestCase):
def test_cancel_stops_worker_and_busy_runner_rejects_second_run(self) -> None:
self.mode_file.write_text("sleep", encoding="utf-8")
self.assertTrue(self.runner.start("manual"))
self.assertEqual(self.runner.current["trigger"], "manual")
self.assertFalse(self.runner.start("manual"))
deadline = time.monotonic() + 10
while self.runner._process is None and time.monotonic() < deadline:
time.sleep(0.05)