-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathCeleryMathGui.py
44 lines (36 loc) · 1.12 KB
/
CeleryMathGui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import sys
from PySide6.QtWidgets import QApplication, QMessageBox
from PySide6.QtCore import QSystemSemaphore, QSharedMemory
from CeleryMath import CeleryMath, seed_everything
WIN_ID = "celeryMath"
SRE_MEM_ID = "celeryMathMem"
def main():
app = QApplication(sys.argv)
semaphore = QSystemSemaphore(WIN_ID, 1)
semaphore.acquire()
if sys.platform != "win32":
nix_fix_shared_mem = QSharedMemory(SRE_MEM_ID)
if nix_fix_shared_mem.attach():
nix_fix_shared_mem.detach()
shared_memory = QSharedMemory(SRE_MEM_ID)
if shared_memory.attach():
is_running = True
else:
shared_memory.create(1)
is_running = False
semaphore.release()
if is_running:
QMessageBox.warning(
None, # type: ignore
"Application already running",
"One instance of the application is already running.",
QMessageBox.StandardButton.Ok,
)
return
mainWindow = CeleryMath()
# mainWindow.flashSplash()
mainWindow.show()
sys.exit(app.exec())
if __name__ == "__main__":
seed_everything(241)
main()