diff --git a/Makefile b/Makefile index d11e6ac21..f3cde37ac 100644 --- a/Makefile +++ b/Makefile @@ -60,7 +60,7 @@ coverage: clean export LANG=en_GB.utf8 pytest -v --random-order --cov-config setup.cfg --cov-report term-missing --cov=mu tests/ -tidy: +tidy: python make.py tidy black: diff --git a/mu/app.py b/mu/app.py index 3a46a13af..36a245177 100644 --- a/mu/app.py +++ b/mu/app.py @@ -297,6 +297,16 @@ def __exit__(self, *args, **kwargs): self._shared_memory.unlock() def acquire(self): + # + # The attach-detach dance is a shim from + # https://stackoverflow.com/questions/42549904/qsharedmemory-is-not-getting-deleted-on-application-crash + # If the existing shared memory is not held by any active application + # (eg because an appimage has hard-crashed) then it will be released + # If the memory is held by an active application it will have no effect + # + self._shared_memory.attach() + self._shared_memory.detach() + if self._shared_memory.attach(): pid = struct.unpack("q", self._shared_memory.data()[:8]) raise MutexError("MUTEX: Mu is already running with pid %d" % pid) @@ -354,7 +364,6 @@ def run(): logging.info("Platform: {}".format(platform.platform())) logging.info("Python path: {}".format(sys.path)) logging.info("Language code: {}".format(i18n.language_code)) - setup_exception_handler() check_only_running_once() diff --git a/setup.cfg b/setup.cfg index 432044306..790b813f0 100644 --- a/setup.cfg +++ b/setup.cfg @@ -23,6 +23,7 @@ exclude = ./.venv*/ ./env/ ./.env/ + ./local-scripts/ max-line-length = 88 [coverage:run]