Skip to content

Commit afdbbcb

Browse files
committed
lowerlayer: catch all exception in the lowerlayer thread
1 parent 931f3c7 commit afdbbcb

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

lowerlayer.py

+18-15
Original file line numberDiff line numberDiff line change
@@ -291,21 +291,24 @@ def _connect(self):
291291

292292
def work(self):
293293
""" runs in a seperate thread """
294-
while self._running:
295-
if not self._control.empty():
296-
control, payload = self._control.get()
297-
if control == MSG_CONNECT:
298-
self._connect()
299-
elif control == MSG_DISCONNECT:
300-
self.ev_disconnect()
301-
break
302-
elif control == MSG_SEND:
303-
self._send_messages.put(payload)
304-
self.ev_enqueue_message()
305-
if self.state != "disconnected":
306-
self._ble_node.waitForNotifications(self.timeout)
307-
else:
308-
time.sleep(0.1)
294+
try:
295+
while self._running:
296+
if not self._control.empty():
297+
control, payload = self._control.get()
298+
if control == MSG_CONNECT:
299+
self._connect()
300+
elif control == MSG_DISCONNECT:
301+
self.ev_disconnect()
302+
break
303+
elif control == MSG_SEND:
304+
self._send_messages.put(payload)
305+
self.ev_enqueue_message()
306+
if self.state != "disconnected":
307+
self._ble_node.waitForNotifications(self.timeout)
308+
else:
309+
time.sleep(0.1)
310+
except Exception as e:
311+
self._error("Exception occured %s" % e)
309312

310313
# user api functions
311314
def disconnect(self):

0 commit comments

Comments
 (0)