fix: address code review feedback

- Add exception handling in run_pipeline to catch unexpected errors
- Remove dead code in THTest (self.name check that never executes)
- Add timeout and concurrency limit tests to test_textfx_runtime_limits.py
This commit is contained in:
2026-03-18 18:15:49 +08:00
parent 1331f8f893
commit 805e60a9ff
3 changed files with 58 additions and 9 deletions

View File

@ -563,12 +563,20 @@ class PipelineRunner:
results: list[TextHandleResult] = []
for statement in pipeline.statements:
if isinstance(statement, IfNode):
results.append(await self._execute_if(statement, istream, env))
elif isinstance(statement, WhileNode):
results.append(await self._execute_while(statement, istream, env))
else:
results.append(await self._execute_group(statement, istream, env))
try:
if isinstance(statement, IfNode):
results.append(await self._execute_if(statement, istream, env))
elif isinstance(statement, WhileNode):
results.append(await self._execute_while(statement, istream, env))
else:
results.append(await self._execute_group(statement, istream, env))
except Exception as e:
logger.error(f"Pipeline execution failed: {e}")
logger.exception(e)
results.append(
TextHandleResult(code=-1, ostream="处理流水线时出现 python 错误")
)
return results
return results

View File

@ -118,9 +118,8 @@ class THTest(TextHandler):
self, env: TextHandlerEnvironment, istream: str | None, args: list[str]
) -> TextHandleResult:
expr = list(args)
if self.name == "[":
pass
# 支持方括号语法:[ expr ] 会自动移除末尾的 ]
if expr and expr[-1] == "]":
expr = expr[:-1]