Spaces:
Running
Running
Do not rely on delete_on_close. It was added in Python 3.12.
Browse files- 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,
|
63 |
) as f:
|
|
|
64 |
f.write(j)
|
65 |
-
|
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):
|