diff --git a/droneapi/lib/__init__.py b/droneapi/lib/__init__.py index b7074ef6b..cc671db4e 100644 --- a/droneapi/lib/__init__.py +++ b/droneapi/lib/__init__.py @@ -395,6 +395,16 @@ def notify_observers(self, attr_name): except Exception as e: print("Error calling observer: ", e) + def remove_all_observers(self): + """ + Internal function. Do not use. + + This method removes all attached observers. + + .. INTERNAL NOTE: (For subclass use only) + """ + self.__observers = {} + class Vehicle(HasObservers): """ The main vehicle API diff --git a/droneapi/module/api.py b/droneapi/module/api.py index 0992a1e7a..18ef09beb 100644 --- a/droneapi/module/api.py +++ b/droneapi/module/api.py @@ -341,6 +341,11 @@ def run(self): self.module.mpstate.rx_blacklist.remove('STATUSTEXT') except: pass # Silently work with old mavproxies + + # Remove all observers. + self.module.vehicle.remove_all_observers() + self.module.vehicle.unset_mavlink_callback() + self.module.thread_remove(self) def __str__(self):