From 73fd52bcec38a9f0ccd2fe78ffb83af1c50f449c Mon Sep 17 00:00:00 2001 From: JarbasAi Date: Thu, 7 Sep 2023 19:16:56 +0100 Subject: [PATCH] rm dead code --- hivemind_core/__main__.py | 2 +- hivemind_core/protocol.py | 8 ++------ hivemind_core/service.py | 10 +--------- 3 files changed, 4 insertions(+), 16 deletions(-) diff --git a/hivemind_core/__main__.py b/hivemind_core/__main__.py index 622e5bd..13b2fc0 100644 --- a/hivemind_core/__main__.py +++ b/hivemind_core/__main__.py @@ -3,7 +3,7 @@ def main(): service = HiveMindService() - service.start() + service.run() if __name__ == "__main__": diff --git a/hivemind_core/protocol.py b/hivemind_core/protocol.py index 608e57c..36144de 100644 --- a/hivemind_core/protocol.py +++ b/hivemind_core/protocol.py @@ -226,12 +226,8 @@ class HiveMindListenerProtocol: mycroft_bus_callback = None # slave asked to inject payload into mycroft bus shared_bus_callback = None # passive sharing of slave device bus (info) - def bind(self, websocket, bus=None): + def bind(self, websocket, bus): websocket.protocol = self - if bus is None: - bus = MessageBusClient() - bus.run_in_thread() - bus.connected_event.wait() self.internal_protocol = HiveMindListenerInternalProtocol(bus) self.internal_protocol.register_bus_handlers() @@ -361,7 +357,7 @@ def handle_handshake_message(self, message: HiveMessage, # while the access key is transmitted, the password never is envelope = payload["envelope"] # TODO - seems tornado never emits these, they never arrive in client - # closing the listener should futures were never awaited + # closing the listener shows futures were never awaited # until this is debugged force to False # client.binarize = payload.get("binarize", False) client.binarize = False diff --git a/hivemind_core/service.py b/hivemind_core/service.py index 4fa4f0e..623a4ad 100644 --- a/hivemind_core/service.py +++ b/hivemind_core/service.py @@ -95,10 +95,6 @@ def on_stopping(): class MessageBusEventHandler(WebSocketHandler): protocol: Optional[HiveMindListenerProtocol] = None - def __init__(self, application, request, **kwargs): - super().__init__(application, request, **kwargs) - self.emitter = EventEmitter() - @staticmethod def decode_auth(auth) -> Tuple[str, str]: userpass_encoded = bytes(auth, encoding="utf-8") @@ -106,9 +102,6 @@ def decode_auth(auth) -> Tuple[str, str]: name, key = userpass_decoded.split(":") return name, key - def on(self, event_name, handler): - self.emitter.on(event_name, handler) - def on_message(self, message): message = self.client.decode(message) LOG.info(f"received {self.client.peer} message: {message}") @@ -163,7 +156,7 @@ def check_origin(self, origin) -> bool: return True -class HiveMindService(Thread): +class HiveMindService: identity = NodeIdentity() def __init__(self, @@ -174,7 +167,6 @@ def __init__(self, stopping_hook: Callable = on_stopping, websocket_config: Optional[Dict[str, Any]] = None): - super().__init__() websocket_config = websocket_config or \ Configuration().get('hivemind_websocket', {}) callbacks = StatusCallbackMap(on_started=started_hook,