Skip to content

Commit

Permalink
Ignore cleanup errors in cache teardown. (#3020)
Browse files Browse the repository at this point in the history
To avoid PermissionError on Windows where certain .pyd files are locked
by current Python process and cannot be deleted.

Fixes #3019.
  • Loading branch information
pbchekin authored Dec 17, 2024
1 parent f1a893a commit 650428b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
16 changes: 10 additions & 6 deletions python/test/regression/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ def device(request):

@pytest.fixture
def fresh_triton_cache():
with tempfile.TemporaryDirectory() as tmpdir:
try:
os.environ["TRITON_CACHE_DIR"] = tmpdir
yield tmpdir
finally:
os.environ.pop("TRITON_CACHE_DIR", None)
try:
with tempfile.TemporaryDirectory() as tmpdir:
try:
os.environ["TRITON_CACHE_DIR"] = tmpdir
yield tmpdir
finally:
os.environ.pop("TRITON_CACHE_DIR", None)
except OSError:
# Ignore errors, such as PermissionError, on Windows
pass
16 changes: 10 additions & 6 deletions python/test/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@ def device(request):

@pytest.fixture
def fresh_triton_cache():
with tempfile.TemporaryDirectory() as tmpdir:
try:
os.environ["TRITON_CACHE_DIR"] = tmpdir
yield tmpdir
finally:
os.environ.pop("TRITON_CACHE_DIR", None)
try:
with tempfile.TemporaryDirectory() as tmpdir:
try:
os.environ["TRITON_CACHE_DIR"] = tmpdir
yield tmpdir
finally:
os.environ.pop("TRITON_CACHE_DIR", None)
except OSError:
# Ignore errors, such as PermissionError, on Windows
pass

0 comments on commit 650428b

Please sign in to comment.