Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6591021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:22:19+00:00 2026-05-25T17:22:19+00:00

I am relatively new to python (already did some 1h scripts like a little

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:22:20+00:00Added an answer on May 25, 2026 at 5:22 pm

    At the most basic level, first of all, you want to provide a basic Plugin class which is a base for all plugins written for your application.

    Next we need to import them all.

    class PluginLoader():
        def __init__(self, path):
            self.path = path
    
        def __iter__(self):
            for (dirpath, dirs, files) in os.walk(self.path):
                if not dirpath in sys.path:
                    sys.path.insert(0, dirpath)
            for file in files:
                    (name, ext) = os.path.splitext(file)
                    if ext == os.extsep + "py":
                        __import__(name, None, None, [''])
            for plugin in Plugin.__subclasses__():
                yield plugin
    

    In Python 2.7 or 3.1+, instead of __import__(name, None, None, ['']), consider:

    import importlib  # just once
    importlib.import_module(name)
    

    This loads every plugin file and gives us all plugins. You would then select your plugins as you saw fit, and then use them:

    from multiprocessing import Process, Pipe
    
    plugins = {}
    
    for plugin in PluginLoader("plugins"):
        ... #select plugin(s)
        if selected:
            plugins[plugin.__name__], child = Pipe()
            p = Process(target=plugin, args=(child,))
            p.start()
    
    ...
    
    for plugin in plugins.values():
        plugin.put("EventHappened")
    
    ...
    
    for plugin in plugins.values():
        event = plugin.get(False)
        if event:
           ... #handle event
    

    This is just what comes to mind at first. Obviously much more would be needed for flesh this out, but it should be a good basis to work from.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a relatively new convert to Python. I've written some code to grab/graph data
I'm relatively new to python and know very little syntax, but I'm willing to
I am relatively new to python. I want to write a script and pass
Relatively new to Python.. I would like to know how to check if a
I am relatively new to python I would like to run a block of
I'm relatively new to Python and am having problems programming with Scapy, the Python
I am relatively new to python and app engine, and I just finished my
I'm relatively new to the Python world, but this seems very straight forward. Google
I'm relatively new to wxPython (but not Python itself), so forgive me if I've
I am relatively new (as in a few days) to Python - I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.