the lock file will be left there forever and cause dead loop, there is a simple fix
import time
import os
def _check_stale_lock(lockfname, timeout=10):
while os.path.exists(lockfname):
lock_time = os.path.getmtime(lockfname)
current_time = time.time()
if current_time - lock_time > timeout: # 10 seconds
logger.warning(f"Lock file {lockfname} is stale, removing it")
os.remove(lockfname)
return True
time.sleep(0.1)
return False
the lock file will be left there forever and cause dead loop, there is a simple fix import time import os def _check_stale_lock(lockfname, timeout=10): while os.path.exists(lockfname): lock_time = os.path.getmtime(lockfname) current_time = time.time() if current_time - lock_time > timeout: # 10 seconds logger.warning(f"Lock file {lockfname} is stale, removing it") os.remove(lockfname) return True time.sleep(0.1) return False
fix bug when dead lock file exists
class Cache_Ext(diskcache.Cache): def getitem(self, key): lockfname = self._key_to_fname(key, diskcache.LOCK) _check_stale_lock(lockfname) super().getitem(key)
diskcache.Cache=Cache_Ext