mirror of
https://github.com/bytedance/deer-flow.git
synced 2026-05-23 08:25:57 +00:00
clarify run creation rollback on cancellation
This commit is contained in:
@@ -142,15 +142,16 @@ class RunManager:
|
|||||||
)
|
)
|
||||||
async with self._lock:
|
async with self._lock:
|
||||||
self._runs[run_id] = record
|
self._runs[run_id] = record
|
||||||
|
persisted = False
|
||||||
try:
|
try:
|
||||||
await self._persist_new_run_to_store(record)
|
await self._persist_new_run_to_store(record)
|
||||||
except asyncio.CancelledError:
|
persisted = True
|
||||||
self._runs.pop(run_id, None)
|
|
||||||
raise
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self._runs.pop(run_id, None)
|
|
||||||
logger.warning("Failed to persist run %s; rolled back in-memory record", run_id, exc_info=True)
|
logger.warning("Failed to persist run %s; rolled back in-memory record", run_id, exc_info=True)
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
|
if not persisted:
|
||||||
|
self._runs.pop(run_id, None)
|
||||||
logger.info("Run created: run_id=%s thread_id=%s", run_id, thread_id)
|
logger.info("Run created: run_id=%s thread_id=%s", run_id, thread_id)
|
||||||
return record
|
return record
|
||||||
|
|
||||||
@@ -349,15 +350,16 @@ class RunManager:
|
|||||||
model_name=model_name,
|
model_name=model_name,
|
||||||
)
|
)
|
||||||
self._runs[run_id] = record
|
self._runs[run_id] = record
|
||||||
|
persisted = False
|
||||||
try:
|
try:
|
||||||
await self._persist_new_run_to_store(record)
|
await self._persist_new_run_to_store(record)
|
||||||
except asyncio.CancelledError:
|
persisted = True
|
||||||
self._runs.pop(run_id, None)
|
|
||||||
raise
|
|
||||||
except Exception:
|
except Exception:
|
||||||
self._runs.pop(run_id, None)
|
|
||||||
logger.warning("Failed to persist run %s; rolled back in-memory record", run_id, exc_info=True)
|
logger.warning("Failed to persist run %s; rolled back in-memory record", run_id, exc_info=True)
|
||||||
raise
|
raise
|
||||||
|
finally:
|
||||||
|
if not persisted:
|
||||||
|
self._runs.pop(run_id, None)
|
||||||
|
|
||||||
if multitask_strategy in ("interrupt", "rollback") and inflight:
|
if multitask_strategy in ("interrupt", "rollback") and inflight:
|
||||||
for r in inflight:
|
for r in inflight:
|
||||||
|
|||||||
Reference in New Issue
Block a user