Skip to content

Commit

Permalink
bugfix: multiple processes initializing code interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
JianxinMa committed Feb 22, 2024
1 parent 7ae0153 commit aa0cc17
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion qwen_agent/tools/code_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
def _fix_secure_write_for_code_interpreter():
if 'linux' in sys.platform.lower():
os.makedirs(WORK_DIR, exist_ok=True)
fname = os.path.join(WORK_DIR, 'test_file_permission.txt')
fname = os.path.join(WORK_DIR,
f'test_file_permission_{os.getpid()}.txt')
if os.path.exists(fname):
os.remove(fname)
with os.fdopen(
Expand All @@ -44,6 +45,8 @@ def _fix_secure_write_for_code_interpreter():
file_mode = stat.S_IMODE(os.stat(fname).st_mode) & 0o6677
if file_mode != 0o0600:
os.environ['JUPYTER_ALLOW_INSECURE_WRITES'] = '1'
if os.path.exists(fname):
os.remove(fname)


_fix_secure_write_for_code_interpreter()
Expand Down

0 comments on commit aa0cc17

Please sign in to comment.