Skip to content

Commit

Permalink
Merge pull request #1184 from meum/exit-if-lockfile-exists
Browse files Browse the repository at this point in the history
Kill process if lockfile already exists
  • Loading branch information
marticliment committed May 12, 2023
2 parents 8687a49 + 9b8ca88 commit eaf205f
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion elevenclock/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,14 @@ def isElevenClockRunningThread():
LockFile = f"ElevenClockRunning{nowTime}"
LockFilePath = os.path.join(os.path.expanduser("~"), ".elevenclock", LockFile)
LockFileLocation = os.path.join(os.path.expanduser("~"), ".elevenclock")
setSettings(LockFile, True, False)
try:
# try to create lockfile, exit if it already exists since this means another process started at the same time
open(LockFilePath, "x").close()
except FileExistsError as e:
globals.newInstanceLaunched = True
print("🟠 KILLING, LOCKFILE ALREADY EXISTS")
killSignal.infoSignal.emit("", "")
return
while True:
try:
if os.path.isfile(os.path.join(LockFileLocation, "ReloadClocks")):
Expand Down

0 comments on commit eaf205f

Please sign in to comment.