From be4e777d225d4791ce1535fc9ac19044aca42269 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Fri, 16 Apr 2021 11:26:29 +0800 Subject: [PATCH] mark our reader thread as daemon, so that closing devices is (kinda) optional --- meshtastic/__init__.py | 2 +- meshtastic/__main__.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/meshtastic/__init__.py b/meshtastic/__init__.py index 5e90061..7049e19 100644 --- a/meshtastic/__init__.py +++ b/meshtastic/__init__.py @@ -740,7 +740,7 @@ class StreamInterface(MeshInterface): self._wantExit = False # FIXME, figure out why daemon=True causes reader thread to exit too early - self._rxThread = threading.Thread(target=self.__reader, args=()) + self._rxThread = threading.Thread(target=self.__reader, args=(), daemon=True) MeshInterface.__init__(self, debugOut=debugOut, noProto=noProto) diff --git a/meshtastic/__main__.py b/meshtastic/__main__.py index b2a773f..83b7d23 100644 --- a/meshtastic/__main__.py +++ b/meshtastic/__main__.py @@ -405,7 +405,10 @@ def subscribe(): """Subscribe to the topics the user probably wants to see, prints output to stdout""" pub.subscribe(onReceive, "meshtastic.receive") # pub.subscribe(onConnection, "meshtastic.connection") - pub.subscribe(onConnected, "meshtastic.connection.established") + + # We now call onConnected from main + # pub.subscribe(onConnected, "meshtastic.connection.established") + # pub.subscribe(onNode, "meshtastic.node") @@ -464,6 +467,9 @@ def common(): else: client = SerialInterface( args.port, debugOut=logfile, noProto=args.noproto) + + # We assume client is fully connected now + onConnected(client) # don't call exit, background threads might be running still # sys.exit(0)