fix delete old state

This commit is contained in:
Yuriy Yuriev
2026-05-29 22:06:34 +07:00
parent b02b7518cf
commit e438f09693
4 changed files with 52 additions and 14 deletions
+15 -7
View File
@@ -135,15 +135,23 @@ class TaskStorage:
return {}
async def save_task(self, task_id: str, params: TaskParams) -> None:
tasks = await self.load_tasks()
tasks[task_id] = params
await self.save_tasks(tasks)
async with self._lock:
try:
data = await asyncio.to_thread(self._load_sync)
data[task_id] = self._params_to_dict(params)
await asyncio.to_thread(self._save_sync, data)
except Exception as e:
logger.error(f"save_task error: {e}")
async def delete_task(self, task_id: str) -> None:
tasks = await self.load_tasks()
if task_id in tasks:
del tasks[task_id]
await self.save_tasks(tasks)
async with self._lock:
try:
data = await asyncio.to_thread(self._load_sync)
if task_id in data:
del data[task_id]
await asyncio.to_thread(self._save_sync, data)
except Exception as e:
logger.error(f"delete_task error: {e}")
class ChatStorage: