diff --git a/src/tribler/core/utilities/process_checker.py b/src/tribler/core/utilities/process_checker.py index 429230bb19e..07583761242 100644 --- a/src/tribler/core/utilities/process_checker.py +++ b/src/tribler/core/utilities/process_checker.py @@ -12,6 +12,9 @@ from tribler.core.utilities.path_util import Path +LOCK_FILE_NAME = 'triblerd.lock' + + @contextmanager def single_tribler_instance(directory: Path): checker = ProcessChecker(directory) @@ -28,11 +31,12 @@ class ProcessChecker: This class contains code to check whether a Tribler process is already running. """ - def __init__(self, directory: Path, lock_file_name: str = 'tribler.lock'): - self.logger = logging.getLogger(self.__class__.__name__) + def __init__(self, directory: Path, lock_file_name: Optional[str] = None): + lock_file_name = lock_file_name or LOCK_FILE_NAME self.lock_file = directory / lock_file_name - self.re_tribler = re.compile(r'tribler\b(?![/\\])') + self.logger = logging.getLogger(self.__class__.__name__) self.logger.info(f'Lock file: {self.lock_file}') + self.re_tribler = re.compile(r'tribler\b(?![/\\])') def check_and_restart_if_necessary(self) -> bool: self.logger.info('Check')