Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 1f7a91a

Browse filesBrowse files
committed
TST: Lock cache directory during cleanup.
This prevents multiple processes from trying to cleanup the directory at the same time (e.g., using `pytest -nauto`).
1 parent 82cb933 commit 1f7a91a
Copy full SHA for 1f7a91a

File tree

Expand file treeCollapse file tree

1 file changed

+11
-9
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-9
lines changed

‎lib/matplotlib/testing/compare.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/compare.py
+11-9Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,15 +321,17 @@ def _clean_conversion_cache():
321321
# (actually an overestimate: we don't convert png baselines and results).
322322
max_cache_size = 2 * baseline_images_size
323323
# Reduce cache until it fits.
324-
cache_stat = {
325-
path: path.stat() for path in _get_cache_path().glob("*")}
326-
cache_size = sum(stat.st_size for stat in cache_stat.values())
327-
paths_by_atime = sorted( # Oldest at the end.
328-
cache_stat, key=lambda path: cache_stat[path].st_atime, reverse=True)
329-
while cache_size > max_cache_size:
330-
path = paths_by_atime.pop()
331-
cache_size -= cache_stat[path].st_size
332-
path.unlink()
324+
with cbook._lock_path(_get_cache_path()):
325+
cache_stat = {
326+
path: path.stat() for path in _get_cache_path().glob("*")}
327+
cache_size = sum(stat.st_size for stat in cache_stat.values())
328+
paths_by_atime = sorted( # Oldest at the end.
329+
cache_stat, key=lambda path: cache_stat[path].st_atime,
330+
reverse=True)
331+
while cache_size > max_cache_size:
332+
path = paths_by_atime.pop()
333+
cache_size -= cache_stat[path].st_size
334+
path.unlink()
333335

334336

335337
@functools.lru_cache() # Ensure this is only registered once.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.