introduce framework class, introduce autodelete announcement on shutdown

This commit is contained in:
dbth
2025-01-02 03:39:07 +01:00
parent 4e3516e004
commit cee488bb70
8 changed files with 272 additions and 67 deletions

29
nostr_dvm/framework.py Normal file
View File

@@ -0,0 +1,29 @@
import os
import signal
import time
class DVMFramework:
dvms = []
def __init__(self):
self.dvms = []
def add(self, dvm):
self.dvms.append(dvm)
def run(self):
for dvm in self.dvms:
dvm.run()
try:
while True:
time.sleep(0.1)
except KeyboardInterrupt:
for dvm in self.dvms:
dvm.join()
print("All DVMs shut down.")
os.kill(os.getpid(), signal.SIGKILL)
exit(1)