From 8921bb83241036a0ee4dab6cbed5fc2d32149723 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sat, 16 Mar 2019 11:09:23 +0530 Subject: [PATCH] Reduce file lock time --- src/calibre/utils/config.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/calibre/utils/config.py b/src/calibre/utils/config.py index b3163e6b49..f74fcb3c7a 100644 --- a/src/calibre/utils/config.py +++ b/src/calibre/utils/config.py @@ -219,17 +219,17 @@ class DynamicConfig(dict): 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)