mirror of
https://github.com/moraroy/NonSteamLaunchers-On-Steam-Deck.git
synced 2026-06-13 04:04:59 +03:00
Implement single instance check with lock file
Add single_instance function to prevent multiple instances.
This commit is contained in:
@@ -38,7 +38,19 @@ from urllib.parse import (
|
|||||||
quote
|
quote
|
||||||
)
|
)
|
||||||
|
|
||||||
|
LOCK_FILE = "/tmp/nslgamescanner.lock"
|
||||||
|
|
||||||
|
def single_instance():
|
||||||
|
global lockfile
|
||||||
|
lockfile = open(LOCK_FILE, "w")
|
||||||
|
|
||||||
|
try:
|
||||||
|
fcntl.flock(lockfile, fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||||
|
except BlockingIOError:
|
||||||
|
print("Another instance is already running. Exiting.")
|
||||||
|
sys.exit(0)
|
||||||
|
|
||||||
|
single_instance()
|
||||||
|
|
||||||
|
|
||||||
# Check the value of the DBUS_SESSION_BUS_ADDRESS environment variable
|
# Check the value of the DBUS_SESSION_BUS_ADDRESS environment variable
|
||||||
|
|||||||
Reference in New Issue
Block a user