File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -1356,7 +1356,7 @@ def cache_lock(self, url):
1356
1356
if os .path .isfile (lock_file ):
1357
1357
try :
1358
1358
# lock file exists, but we need to check pid as well in case the process died
1359
- with open (lock_file , 'r' ) as f :
1359
+ with open (lock_file , 'r' , 0 ) as f :
1360
1360
pid = f .read (8 )
1361
1361
if pid and int (pid ) != os .getpid ():
1362
1362
if self .pid_exists (pid ):
@@ -1373,8 +1373,10 @@ def cache_lock(self, url):
1373
1373
break
1374
1374
1375
1375
if can_lock :
1376
- with open (lock_file , 'wb' ) as f :
1376
+ with open (lock_file , 'wb' , 0 ) as f :
1377
1377
f .write (str (os .getpid ()))
1378
+ f .flush ()
1379
+
1378
1380
else :
1379
1381
error ("Exceeded 5 minutes limit while waiting for other process to finish caching" )
1380
1382
except Exception :
@@ -1387,7 +1389,7 @@ def cache_unlock(self, url):
1387
1389
lock_file = os .path .join (cpath , '.lock' )
1388
1390
if os .path .isfile (lock_file ):
1389
1391
try :
1390
- with open (lock_file ) as f :
1392
+ with open (lock_file , 'r' , 0 ) as f :
1391
1393
pid = f .read (8 )
1392
1394
if int (pid ) == os .getpid ():
1393
1395
os .remove (lock_file )
You can’t perform that action at this time.
0 commit comments