Skip to content

Commit 09b7185

Browse files
authored
Fix file not being flushed bug (microsoft#2003)
1 parent e80ccd0 commit 09b7185

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

autogen/coding/local_commandline_code_executor.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ def execute_code_blocks(self, code_blocks: List[CodeBlock]) -> CommandLineCodeRe
136136
filename = f"tmp_code_{code_hash}.{'py' if lang.startswith('python') else lang}"
137137

138138
written_file = (self._work_dir / filename).resolve()
139-
written_file.open("w", encoding="utf-8").write(code)
139+
with written_file.open("w", encoding="utf-8") as f:
140+
f.write(code)
140141
file_names.append(written_file)
141142

142143
program = sys.executable if lang.startswith("python") else _cmd(lang)

0 commit comments

Comments
 (0)