File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -196,7 +196,7 @@ def _receiveFromRadioImpl(self):
196196
197197 def _sendToRadioImpl (self , toRadio ):
198198 b = toRadio .SerializeToString ()
199- if b :
199+ if b and self . client : # we silently ignore writes while we are shutting down
200200 logging .debug (f"TORADIO write: { b .hex ()} " )
201201 try :
202202 self .client .write_gatt_char (
@@ -219,10 +219,11 @@ def close(self):
219219
220220 if self ._want_receive :
221221 self .want_receive = False # Tell the thread we want it to stop
222- self ._receiveThread .join (
223- timeout = 2
224- ) # If bleak is hung, don't wait for the thread to exit (it is critical we disconnect)
225- self ._receiveThread = None
222+ if self ._receiveThread :
223+ self ._receiveThread .join (
224+ timeout = 2
225+ ) # If bleak is hung, don't wait for the thread to exit (it is critical we disconnect)
226+ self ._receiveThread = None
226227
227228 if self .client :
228229 atexit .unregister (self ._exit_handler )
You can’t perform that action at this time.
0 commit comments