def start(self): self.initialize_logger(self.args.debug) try: os.makedirs(config_dir) except OSError: pass # Acquire a filesystem lock to prevent multiple instances from running lock = FilesystemLock( os.path.join(config_dir, "{}.lock".format(APP_NAME))) lock.acquire() logging.debug("Core starting with args: %s", self.args) logging.debug("Loaded config.txt settings: %s", settings) self.show_message() self.gui = Gui(self) self.gui.show_systray() reactor.callLater(0, self.start_gateways) reactor.run() for nodedir in get_nodedirs(config_dir): Tahoe(nodedir, executable=self.executable).kill() lock.release()
def test_lock_release(tmpdir): lock = FilesystemLock(os.path.join(str(tmpdir), "test.lock")) lock.acquire() lock.release() lock.acquire() lock.release()
def test_lock_acquire_raise_filesystemlockerror_from_second_instance(tmpdir): lock_1 = FilesystemLock(os.path.join(str(tmpdir), "test.lock")) lock_1.acquire() lock_2 = FilesystemLock(os.path.join(str(tmpdir), "test.lock")) with pytest.raises(FilesystemLockError): lock_2.acquire()
def test_lock_acquire_raise_filesystemlockerror_on_second_call(tmpdir): lock = FilesystemLock(os.path.join(str(tmpdir), "test.lock")) lock.acquire() with pytest.raises(FilesystemLockError): lock.acquire()
def test_lock_acquire_filepath_created(tmpdir): lock = FilesystemLock(os.path.join(str(tmpdir), "test.lock")) lock.acquire() assert os.path.isfile(lock.filepath)
def test_lock_acquire(tmpdir): lock = FilesystemLock(os.path.join(str(tmpdir), "test.lock")) lock.acquire() assert lock.fd