Skip to content

Commit

Permalink
fix: Python执行
Browse files Browse the repository at this point in the history
  • Loading branch information
Scorpion1221 committed Oct 25, 2024
1 parent 82886de commit ff689b0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions api/core/helper/code_executor/code_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,13 @@ def execute_workflow_code_template(cls, language: CodeLanguage, code: str, input
raise e

return template_transformer.transform_response(response)

class Capturing(list):
def __enter__(self):
self._stdout = sys.stdout
sys.stdout = self._stringio = StringIO()
return self
def __exit__(self, *args):
self.extend(self._stringio.getvalue().splitlines())
del self._stringio # free up some memory
sys.stdout = self._stdout

0 comments on commit ff689b0

Please sign in to comment.