MCPcopy
hub / github.com/PyQt5/PyQt / SharedApplication

Class SharedApplication

Demo/Lib/Application.py:18–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16
17
18class SharedApplication(QApplication):
19
20 def __init__(self, *args, **kwargs):
21 super(SharedApplication, self).__init__(*args, **kwargs)
22 self._running = False
23 key = "SharedApplication"
24 self._memory = QSharedMemory(key, self)
25
26 isAttached = self._memory.isAttached()
27 print("isAttached", isAttached)
28 if isAttached: # 如果进程附加在共享内存上
29 detach = self._memory.detach() # 取消进程附加在共享内存上
30 print("detach", detach)
31
32 if self._memory.create(1) and self._memory.error() != QSharedMemory.AlreadyExists:
33 # 创建共享内存,如果创建失败,则说明已经创建,否则未创建
34 print("create ok")
35 else:
36 print("create failed")
37 self._running = True
38 del self._memory
39
40 def isRunning(self):
41 return self._running
42
43
44class QSingleApplication(QApplication):

Callers 1

SharedMemory.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected