fix: preserve task stop intent and guard remote execution boundaries

This commit is contained in:
Xin Wang
2026-10-23 19:53:17 +08:00
parent 8ac75a1873
commit 89c3bad58e
16 changed files with 199 additions and 20 deletions
+24
View File
@@ -106,6 +106,30 @@ class TaskServiceTest(unittest.IsolatedAsyncioTestCase):
await self.wait_status(second["id"], "cancelled")
self.assertEqual(SimulatedExecutor.calls, 1)
async def test_restart_retries_pending_stop_instead_of_resuming_execution(self):
SimulatedExecutor.confirms_stop = False
task = await self.submit()
await self.wait_status(task["id"], "running")
await self.service.cancel(task["id"])
async with asyncio.timeout(2):
while self.service.runtime.executor.active_jobs:
await asyncio.sleep(.005)
await self.service.close()
SimulatedExecutor.confirms_stop = True
await self.service.start()
await self.wait_status(task["id"], "cancelled")
self.assertEqual(SimulatedExecutor.calls, 1)
async def test_unconfirmed_remote_stop_blocks_the_next_submission(self):
SimulatedExecutor.confirms_stop = False
first = await self.submit("call_first")
await self.wait_status(first["id"], "running")
second = await self.submit("call_second")
await self.service.cancel(first["id"])
await self.wait_status(second["id"], "failed")
self.assertEqual(SimulatedExecutor.calls, 1)
self.assertFalse((await self.service.get(second["id"])).remote_handle)
async def test_restart_observes_existing_remote_handle(self):
task = await self.submit()
await self.wait_status(task["id"], "running")