mirror of
git://github.com/kovidgoyal/calibre.git
synced 2025-12-27 23:34:28 +01:00
Reduce file lock time
This commit is contained in:
parent
138a0338f7
commit
8921bb8324
1 changed files with 11 additions and 11 deletions
|
|
@ -219,17 +219,17 @@ def refresh(self, clear_current=True):
|
|||
d = {}
|
||||
if os.path.exists(self.file_path):
|
||||
with ExclusiveFile(self.file_path) as f:
|
||||
raw = f.read()
|
||||
try:
|
||||
d = cPickle.loads(raw) if raw.strip() else {}
|
||||
except SystemError:
|
||||
pass
|
||||
except Exception:
|
||||
print('WARNING: Failed to unpickle stored config object, ignoring')
|
||||
if DEBUG:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
d = {}
|
||||
raw = f.read().strip()
|
||||
try:
|
||||
d = cPickle.loads(raw) if raw else {}
|
||||
except SystemError:
|
||||
pass
|
||||
except Exception:
|
||||
print('WARNING: Failed to unpickle stored config object, ignoring')
|
||||
if DEBUG:
|
||||
import traceback
|
||||
traceback.print_exc()
|
||||
d = {}
|
||||
if clear_current:
|
||||
self.clear()
|
||||
self.update(d)
|
||||
|
|
|
|||
Loading…
Reference in a new issue