darabos commited on
Commit
2c16673
·
1 Parent(s): 03b7855

Do not rely on delete_on_close. It was added in Python 3.12.

Browse files
Files changed (1) hide show
  1. server/workspace.py +3 -3
server/workspace.py CHANGED
@@ -59,11 +59,11 @@ def save(ws: Workspace, path: str):
59
  dirname, basename = os.path.split(path)
60
  # Create temp file in the same directory to make sure it's on the same filesystem.
61
  with tempfile.NamedTemporaryFile(
62
- "w", prefix=f".{basename}.", dir=dirname, delete_on_close=False
63
  ) as f:
 
64
  f.write(j)
65
- f.close()
66
- os.replace(f.name, path)
67
 
68
 
69
  def load(path: str):
 
59
  dirname, basename = os.path.split(path)
60
  # Create temp file in the same directory to make sure it's on the same filesystem.
61
  with tempfile.NamedTemporaryFile(
62
+ "w", prefix=f".{basename}.", dir=dirname, delete=False
63
  ) as f:
64
+ temp_name = f.name
65
  f.write(j)
66
+ os.replace(temp_name, path)
 
67
 
68
 
69
  def load(path: str):