Skip to content

Commit d0618d3

Browse files
committed
pyplugins: alter unloading behavior wrt __main_loop_wait
fixup slightly safer
1 parent 7d91382 commit d0618d3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

panda/python/core/pandare/panda.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,13 +744,23 @@ def unload_plugin(self, name):
744744
self.libpanda.panda_unload_plugin_by_name(name_ffi)
745745

746746
def _unload_pyplugins(self):
747+
'''
748+
Unload Python plugins first.
749+
750+
We have to be careful to not remove __main_loop_wait because we're executing inside of __main_loop_wait and it more work to do
751+
752+
We achieve this by first popping main loop wait and then re-adding it after unloading all other callbacks
753+
'''
754+
mlw = self.registered_callbacks.pop("__main_loop_wait")
755+
747756
# First unload python plugins, should be safe to do anytime
748-
while len(list(self.registered_callbacks)) > 0:
757+
while self.registered_callbacks:
749758
try:
750759
self.delete_callback(list(self.registered_callbacks.keys())[0])
751760
except IndexError:
752761
continue
753-
#self.disable_callback(name)
762+
763+
self.registered_callbacks["__main_loop_wait"] = mlw
754764

755765
# Next, unload any pyplugins
756766
if hasattr(self, "_pyplugin_manager"):

0 commit comments

Comments
 (0)