Initialize cache directory in isolation

Creating and initializing the cache directory is interruptible; this
avoids a pathological case where interrupting a cache write can cause
the cache directory to never be properly initialized with its supporting
files.

Unify `Cache.mkdir` with `Cache.set` while I'm here so the former also
properly initializes the cache directory.

Closes #12167.
This commit is contained in:
Tamir Duberstein
2024-03-29 15:51:51 +00:00
parent 381593ccf0
commit 2e65f4e3ac
3 changed files with 34 additions and 19 deletions

View File

@@ -1731,8 +1731,8 @@ class TestEarlyRewriteBailout:
import os
import tempfile
with tempfile.TemporaryDirectory() as d:
os.chdir(d)
with tempfile.TemporaryDirectory() as newpath:
os.chdir(newpath)
""",
"test_test.py": """\
def test():