[Enhancement] Engine runtime errors (#2426)
Signed-off-by: Daniel Huang <daniel1.huang@intel.com> Signed-off-by: Daniel Huang <pilotflyer824@gmail.com> Signed-off-by: bjf-frz <frz123db@gmail.com> Co-authored-by: Chenguang Zheng <645327136@qq.com> Co-authored-by: Zhou Taichang <tzhouam@connect.ust.hk> Co-authored-by: Hongsheng Liu <liuhongsheng4@huawei.com> Co-authored-by: bjf-frz <frz123db@gmail.com>
This commit is contained in:
23 files changed
+1597
-98
No files matched your search
@@ -493,6 +493,9 @@ class AsyncOmni(EngineClient, OmniBase):
|
||||
|
||||
stage_id = result.get("stage_id", 0)
|
||||
|
||||
if result.get("type") == "error" and result.get("fatal"):
|
||||
raise EngineDeadError(result.get("error", ""))
|
||||
|
||||
# Check for errors
|
||||
if "error" in result:
|
||||
logger.error(
|
||||
@@ -503,6 +506,8 @@ class AsyncOmni(EngineClient, OmniBase):
|
||||
)
|
||||
raise RuntimeError(result)
|
||||
|
||||
self._check_engine_output_error(result, request_id, stage_id)
|
||||
|
||||
# Process the result (constructs OmniRequestOutput)
|
||||
output_to_yield = self._process_single_result(
|
||||
result,
|
||||
@@ -575,6 +580,16 @@ class AsyncOmni(EngineClient, OmniBase):
|
||||
|
||||
except asyncio.CancelledError:
|
||||
raise
|
||||
except EngineDeadError as e:
|
||||
logger.error("[AsyncOmni] Engine dead: %s", e)
|
||||
for req_state in list(self.request_states.values()):
|
||||
error_msg = {
|
||||
"type": "error",
|
||||
"error": str(e),
|
||||
"fatal": True,
|
||||
"request_id": req_state.request_id,
|
||||
}
|
||||
await req_state.queue.put(error_msg)
|
||||
except Exception as e:
|
||||
logger.exception("[AsyncOmni] final_output_loop failed.")
|
||||
for req_state in list(self.request_states.values()):
|
||||
@@ -841,12 +856,21 @@ class AsyncOmni(EngineClient, OmniBase):
|
||||
@property
|
||||
def is_running(self) -> bool:
|
||||
"""Check if the engine is running."""
|
||||
return self.final_output_task is not None and not self.final_output_task.done()
|
||||
orchestrator_alive = self.engine.is_alive()
|
||||
task_alive = self.final_output_task is not None and not self.final_output_task.done()
|
||||
return orchestrator_alive and task_alive
|
||||
|
||||
@property
|
||||
def errored(self) -> bool:
|
||||
"""Whether orchestrator thread has stopped unexpectedly."""
|
||||
return not self.engine.is_alive()
|
||||
"""Whether the engine is in a non-recoverable error state.
|
||||
|
||||
Delegates to ``OmniBase.errored`` which checks the orchestrator
|
||||
thread and all stage clients. Redeclared here to satisfy the
|
||||
``EngineClient`` abstract-property requirement (Python's ABC
|
||||
mechanism does not resolve abstract methods from sibling MRO
|
||||
entries).
|
||||
"""
|
||||
return OmniBase.errored.fget(self) # type: ignore[union-attr]
|
||||
|
||||
@property
|
||||
def _name(self) -> str:
|
||||
|
||||
Reference in new issue
Block a user