Skip to content

Commit

Permalink
pypluginmanager: make deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
lacraig2 committed Aug 20, 2024
1 parent 6eebe0f commit aafcd05
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions panda/python/core/pandare/pypluginmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
from pathlib import Path
from pandare import PyPlugin
import datetime
import inspect
import importlib.util

Expand Down Expand Up @@ -197,6 +198,7 @@ def load(self, pluginclasses, args=None, template_dir=None):
self.plugins[name].__preinit__(self, args)
self.get_ppp_funcs(self.plugins[name])
self.plugins[name].__init__(self.panda)
self.plugins[name].load_time = datetime.datetime.now()

# Setup webserver if necessary
if self.flask and hasattr(self.plugins[name], 'webserver_init') and \
Expand Down Expand Up @@ -272,8 +274,10 @@ def unload_all(self):
'''
Unload all PyPlugins
'''
while self.plugins:
name, cls = self.plugins.popitem()
# unload in reverse order of load time
plugin_list = {k:v for k,v in reversed(sorted(self.plugins.items(), key=lambda x: x[1].load_time))}
while plugin_list:
name, cls = plugin_list.popitem()
self.unload(cls, do_del=False)

def is_loaded(self, pluginclass):
Expand Down

0 comments on commit aafcd05

Please sign in to comment.