mark our reader thread as daemon, so that closing devices is (kinda) optional

This commit is contained in:
Kevin Hester
2021-04-16 11:26:29 +08:00
parent 4a9b94d406
commit be4e777d22
2 changed files with 8 additions and 2 deletions

View File

@@ -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)

View File

@@ -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)