From f28b36a8788f1c2b54033b755dbadeb5646434ba Mon Sep 17 00:00:00 2001 From: yzqzss Date: Sat, 12 Oct 2024 19:16:55 +0800 Subject: [PATCH] refactor: dumpLock --- dokuWikiDumper/utils/dump_lock.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/dokuWikiDumper/utils/dump_lock.py b/dokuWikiDumper/utils/dump_lock.py index 9be8ca1..b43cdd6 100644 --- a/dokuWikiDumper/utils/dump_lock.py +++ b/dokuWikiDumper/utils/dump_lock.py @@ -1,5 +1,4 @@ import os -import sys import importlib.util class AlreadyRunningError(Exception): @@ -40,16 +39,13 @@ def wrapper(*args, **kwargs): class DumpLock_Fcntl(): - fcntl = None - try: - import fcntl - except ModuleNotFoundError: - pass - def __init__(self, lock_dir): - if self.fcntl is None: - raise(ModuleNotFoundError("No module named 'fcntl'", name='fcntl')) - + try: + import fcntl + except ModuleNotFoundError: + raise + + self.fcntl = fcntl self.lock_file = os.path.join(lock_dir, LOCK_FILENAME) self.lock_file_fd = None