Skip to content

Commit

Permalink
perf: 优化 pipeline 处理时的报错
Browse files Browse the repository at this point in the history
  • Loading branch information
RockChinQ committed Jul 4, 2024
1 parent d362991 commit b5d33ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pkg/core/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class Query(pydantic.BaseModel):
resp_message_chain: typing.Optional[list[mirai.MessageChain]] = None
"""回复消息链,从resp_messages包装而得"""

# ======= 内部保留 =======
current_stage: "pkg.pipeline.stagemgr.StageInstContainer" = None

class Config:
arbitrary_types_allowed = True

Expand Down
4 changes: 3 additions & 1 deletion pkg/pipeline/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ async def _execute_from_stage(

while i < len(self.ap.stage_mgr.stage_containers):
stage_container = self.ap.stage_mgr.stage_containers[i]

query.current_stage = stage_container # 标记到 Query 对象里

result = stage_container.inst.process(query, stage_container.inst_name)

Expand Down Expand Up @@ -162,7 +164,7 @@ async def process_query(self, query: entities.Query):
try:
await self._execute_from_stage(0, query)
except Exception as e:
self.ap.logger.error(f"处理请求时出错 query_id={query.query_id}: {e}")
self.ap.logger.error(f"处理请求时出错 query_id={query.query_id} stage={query.current_stage.inst_name} : {e}")
self.ap.logger.debug(f"Traceback: {traceback.format_exc()}")
# traceback.print_exc()
finally:
Expand Down

0 comments on commit b5d33ef

Please sign in to comment.