Skip to content

Commit 0a2c439

Browse files
committed
Ignore errors while releasing cache
1 parent cfd09c8 commit 0a2c439

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

mbed/mbed.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,17 +1409,20 @@ def cache_unlock(self, url):
14091409

14101410
lock_dir = os.path.join(cpath, '.lock')
14111411
lock_file = os.path.join(lock_dir, 'pid')
1412-
if os.path.exists(lock_dir):
1413-
if os.path.isfile(lock_file):
1414-
try:
1415-
with open(lock_file, 'r', 0) as f:
1416-
pid = f.read(8)
1417-
if int(pid) != os.getpid():
1418-
error("Cache lock file exists with a different pid (\"%s\" vs \"%s\")" % (pid, os.getpid()))
1419-
except OSError:
1420-
error("Unable to unlock cache dir \"%s\"" % (cpath))
1421-
os.remove(lock_file)
1422-
os.rmdir(lock_dir)
1412+
try:
1413+
if os.path.exists(lock_dir):
1414+
if os.path.isfile(lock_file):
1415+
try:
1416+
with open(lock_file, 'r', 0) as f:
1417+
pid = f.read(8)
1418+
if int(pid) != os.getpid():
1419+
error("Cache lock file exists with a different pid (\"%s\" vs \"%s\")" % (pid, os.getpid()))
1420+
except OSError:
1421+
error("Unable to unlock cache dir \"%s\"" % (cpath))
1422+
os.remove(lock_file)
1423+
os.rmdir(lock_dir)
1424+
except (OSError) as e:
1425+
pass
14231426
return True
14241427

14251428
def pid_exists(self, pid):

0 commit comments

Comments
 (0)