diff --git a/cflib/crazyflie/__init__.py b/cflib/crazyflie/__init__.py index cc4868e50..db6ba79bd 100644 --- a/cflib/crazyflie/__init__.py +++ b/cflib/crazyflie/__init__.py @@ -393,7 +393,8 @@ class _IncomingPacketHandler(Thread): """Handles incoming packets and sends the data to the correct receivers""" def __init__(self, cf): - Thread.__init__(self) + Thread.__init__(self, name='IncomingPacketHandlerThread') + self.daemon = True self.cf = cf self.cb = [] diff --git a/cflib/crazyflie/param.py b/cflib/crazyflie/param.py index bfc4e254b..605b543d8 100644 --- a/cflib/crazyflie/param.py +++ b/cflib/crazyflie/param.py @@ -155,9 +155,6 @@ def __init__(self, crazyflie): self.all_update_callback = Caller() self.param_updater = None - self.param_updater = _ParamUpdater(self.cf, self._useV2, self._param_updated) - self.param_updater.start() - self.cf.disconnected.add_callback(self._disconnected) self.cf.connection_requested.add_callback(self._connection_requested) @@ -289,12 +286,15 @@ def refresh_done(): def _connection_requested(self, uri): # Reset the internal state on connect to make sure we have a clean state + self.param_updater = _ParamUpdater(self.cf, self._useV2, self._param_updated) + self.param_updater.start() self.is_updated = False self.toc = Toc() self.values = {} self._initialized.clear() def _disconnected(self, uri): + logger.info('Disconnected, cleaning up threads') """Disconnected callback from Crazyflie API""" if self.param_updater is not None: self.param_updater.close() @@ -311,8 +311,7 @@ def request_param_update(self, complete_name): Request an update of the value for the supplied parameter. """ if self.param_updater is None: - self.param_updater = _ParamUpdater(self.cf, self._useV2, self._param_updated) - self.param_updater.start() + raise Exception('Param updater not initialized, did you call open_connection?') self.param_updater.request_param_update( self.toc.get_element_id(complete_name)) diff --git a/cflib/crtp/radiodriver.py b/cflib/crtp/radiodriver.py index b2b280ddd..3f0894fb6 100644 --- a/cflib/crtp/radiodriver.py +++ b/cflib/crtp/radiodriver.py @@ -542,6 +542,7 @@ def __init__(self, radio, inQueue, outQueue, self._has_safelink = False self._link = link + self.daemon = True def stop(self): """ Stop the thread """