Skip to content

Commit 650428b

Browse files
authored
Ignore cleanup errors in cache teardown. (#3020)
To avoid PermissionError on Windows where certain .pyd files are locked by current Python process and cannot be deleted. Fixes #3019.
1 parent f1a893a commit 650428b

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

python/test/regression/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ def device(request):
1414

1515
@pytest.fixture
1616
def fresh_triton_cache():
17-
with tempfile.TemporaryDirectory() as tmpdir:
18-
try:
19-
os.environ["TRITON_CACHE_DIR"] = tmpdir
20-
yield tmpdir
21-
finally:
22-
os.environ.pop("TRITON_CACHE_DIR", None)
17+
try:
18+
with tempfile.TemporaryDirectory() as tmpdir:
19+
try:
20+
os.environ["TRITON_CACHE_DIR"] = tmpdir
21+
yield tmpdir
22+
finally:
23+
os.environ.pop("TRITON_CACHE_DIR", None)
24+
except OSError:
25+
# Ignore errors, such as PermissionError, on Windows
26+
pass

python/test/unit/conftest.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,13 @@ def device(request):
1414

1515
@pytest.fixture
1616
def fresh_triton_cache():
17-
with tempfile.TemporaryDirectory() as tmpdir:
18-
try:
19-
os.environ["TRITON_CACHE_DIR"] = tmpdir
20-
yield tmpdir
21-
finally:
22-
os.environ.pop("TRITON_CACHE_DIR", None)
17+
try:
18+
with tempfile.TemporaryDirectory() as tmpdir:
19+
try:
20+
os.environ["TRITON_CACHE_DIR"] = tmpdir
21+
yield tmpdir
22+
finally:
23+
os.environ.pop("TRITON_CACHE_DIR", None)
24+
except OSError:
25+
# Ignore errors, such as PermissionError, on Windows
26+
pass

0 commit comments

Comments
 (0)