Refactor thread handling
This commit is contained in:
parent
035576dff0
commit
ba0d687b63
@ -39,6 +39,18 @@ class FieldPOC:
|
||||
self._routing = routing.Routing(self)
|
||||
self._ywsd = ywsd.Ywsd(self)
|
||||
|
||||
logger.info("initialising threads")
|
||||
self.threads = {
|
||||
"controller": threading.Thread(target=self._controller.run),
|
||||
"dect": threading.Thread(target=self._dect.run),
|
||||
"routing": threading.Thread(target=self._routing.run),
|
||||
"ywsd": threading.Thread(target=self._ywsd.run, daemon=True),
|
||||
}
|
||||
|
||||
# Set thread names
|
||||
for name, thread in self.threads.items():
|
||||
thread.name = name
|
||||
|
||||
def queue_all(self, msg):
|
||||
"""
|
||||
Send message to every queue
|
||||
@ -60,21 +72,16 @@ class FieldPOC:
|
||||
logger.info("initialization complete")
|
||||
|
||||
def run(self):
|
||||
logger.info("starting components")
|
||||
"""
|
||||
Start FieldPOC
|
||||
"""
|
||||
|
||||
self._controller_thread = threading.Thread(target=self._controller.run)
|
||||
self._controller_thread.start()
|
||||
logger.info("starting threads")
|
||||
|
||||
self._dect_thread = threading.Thread(target=self._dect.run)
|
||||
self._dect_thread.start()
|
||||
for name, thread in self.threads.items():
|
||||
thread.start()
|
||||
|
||||
self._routing_thread = threading.Thread(target=self._routing.run)
|
||||
self._routing_thread.start()
|
||||
|
||||
self._ywsd_thread = threading.Thread(target=self._ywsd.run, daemon=True)
|
||||
self._ywsd_thread.start()
|
||||
|
||||
logger.info("started components")
|
||||
logger.info("started threads")
|
||||
|
||||
def reload_extensions(self):
|
||||
self._load_extensions()
|
||||
|
Loading…
Reference in New Issue
Block a user