mirror of
https://github.com/aljazceru/nostrdvm.git
synced 2025-12-23 00:44:26 +01:00
introduce framework class, introduce autodelete announcement on shutdown
This commit is contained in:
29
nostr_dvm/framework.py
Normal file
29
nostr_dvm/framework.py
Normal 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)
|
||||
|
||||
Reference in New Issue
Block a user