I am relatively new to python (already did some 1h scripts like a little webserver or a local network chat) and want to program a plugin manager in it. My idea is, that there is an interface for plugins, that has the following features:
getDependencies -> all dependencies of the plugin to other plugins
getFunctions -> all functions that this plugin introduces
initialize -> a function that is called when loading the plugin
(I could imagine to have a topological sorting algorithm on the dependencies to decide the order in which the plugins are initialized.)
I would like to implement multithreading, meaning that each plugin runs in its own thread, that has a working queue of function-calls that will be executed serially. When a plugin calls the function of another plugin it calls the manager who will in turn insert the function-call into the queue of the other plugin.
Further the manager should provide some kind of event system in which the plugins can register their own events and become listeners to the events of others.
Also I want to be able to reload a plugin if the code has changed or its thread crashed, without shutting down the manager/application. I already read How do I unload (reload) a Python module? in conjunction with this.
To make it clear once more: The manager should not provide any other functionality than supporting its plugins with a common communication interface to each other, the ability to run side by side (in a multithreaded manner without requiring the plugins to be aware of this) and restoring updated/crashed plugins.
So my questions are: Is it possible to do this in python? And if yes are there design mistakes in this rough sketch? I would appreciate any good advice on this.
Other "literature": Implementing a Plugin System in Python