File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed
Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,19 @@ def _clear_all_cache_files(self) -> None:
145145 path , name = os .path .split (self .cache_fpath )
146146 for subpath in os .listdir (path ):
147147 if subpath .startswith (f"{ name } _" ):
148- os .remove (os .path .join (path , subpath ))
148+ fpath = os .path .join (path , subpath )
149+ # Retry loop to handle Windows mandatory file-locking (WinError 32):
150+ # portalocker holds an exclusive lock while a thread is computing,
151+ # so os.remove() may fail transiently until the lock is released.
152+ for attempt in range (3 ):
153+ try :
154+ os .remove (fpath )
155+ break
156+ except PermissionError :
157+ if attempt < 2 :
158+ time .sleep (0.1 * (attempt + 1 ))
159+ else :
160+ raise
149161
150162 def _clear_being_calculated_all_cache_files (self ) -> None :
151163 path , name = os .path .split (self .cache_fpath )
You can’t perform that action at this time.
0 commit comments