File tree 1 file changed +12
-10
lines changed
1 file changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -284,31 +284,33 @@ def create_lock_file(self):
284
284
self .clear_all_thumbnails ()
285
285
286
286
# Write lock file (try a few times if failure)
287
- attempts = 5
288
- while attempts > 0 :
287
+ for attempt in range (5 ):
289
288
try :
290
289
# Create lock file
291
290
with open (lock_path , 'w' ) as f :
292
291
f .write (lock_value )
292
+ log .debug ("Wrote value {} to lock file {}" .format (
293
+ lock_value , lock_path ))
293
294
break
294
- except Exception :
295
- log .debug ('Failed to write lock file (attempt: %s)' % attempts )
296
- attempts -= 1
295
+ except OSError :
296
+ log .debug ('Failed to write lock file (attempt: {})' . format (
297
+ attempt ), exc_info = 1 )
297
298
sleep (0.25 )
298
299
299
300
def destroy_lock_file (self ):
300
301
"""Destroy the lock file"""
301
302
lock_path = os .path .join (info .USER_PATH , ".lock" )
302
303
303
304
# Remove file (try a few times if failure)
304
- attempts = 5
305
- while attempts > 0 :
305
+ for attempt in range (5 ):
306
306
try :
307
307
os .remove (lock_path )
308
+ log .debug ("Removed lock file {}" .format (lock_path ))
308
309
break
309
- except Exception :
310
- log .debug ('Failed to destroy lock file (attempt: %s)' % attempts )
311
- attempts -= 1
310
+ except FileNotFoundError :
311
+ break
312
+ except OSError :
313
+ log .debug ('Failed to destroy lock file (attempt: %s)' % attempt , exc_info = 1 )
312
314
sleep (0.25 )
313
315
314
316
def tail_file (self , f , n , offset = None ):
You can’t perform that action at this time.
0 commit comments