Skip to content

Commit

Permalink
fix: revert hard file lock as not released at shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
Crissium committed Apr 16, 2024
1 parent 0882ccc commit 4bfcbea
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions server/app/settings.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import atexit
import copy
import os
import sys
Expand Down Expand Up @@ -40,21 +39,6 @@ class Settings:
'DSL (.dsl/.dsl.dz)': ['.dsl', '.dz']
}

LOCK_FILE = os.path.join(APP_RESOURCES_ROOT, 'lock')

@classmethod
def _acquire_lock(cls) -> None:
if os.path.isfile(cls.LOCK_FILE):
logger.error('Another instance of the application is running.')
sys.exit(1)

with open(cls.LOCK_FILE, 'w') as f:
f.write('locked')

@classmethod
def _release_lock(cls) -> None:
os.remove(cls.LOCK_FILE)

PREFERENCES_FILE = os.path.join(APP_RESOURCES_ROOT, 'preferences.yaml')
# a dict with three fields: listening_address, suggestions_mode, running_mode

Expand Down Expand Up @@ -234,9 +218,6 @@ def change_suggestions_mode_from_right_side_to_both_sides(self) -> None:
preferences_file.write(preferences)

def __init__(self) -> None:
self._acquire_lock()
atexit.register(self._release_lock)

self._config_files_lock = threading.Lock()
self._scan_lock = threading.Lock()

Expand Down

0 comments on commit 4bfcbea

Please sign in to comment.