File tree Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Expand file tree Collapse file tree 1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -321,15 +321,17 @@ def _clean_conversion_cache():
321
321
# (actually an overestimate: we don't convert png baselines and results).
322
322
max_cache_size = 2 * baseline_images_size
323
323
# 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 ()
333
335
334
336
335
337
@functools .lru_cache () # Ensure this is only registered once.
You can’t perform that action at this time.
0 commit comments