I'm planning to use the EntryPoint facility for plugins in my application, and I was just thinking about what it would take to load a new plugin. My best guess is that, right now, it would take a restart... which is not bad, but not ideal either. In order to dynamically add a plugin at runtime, it seems like I would need 1) a way to get a new egg loaded 2) a notification to go out to the parts of the code that care about the entry points for a particular name or group. Does anyone else care about being able to add plugins without a restart, or is it just me? Kevin
At 07:07 AM 8/30/2005 -0400, Kevin Dangoor wrote:
I'm planning to use the EntryPoint facility for plugins in my application, and I was just thinking about what it would take to load a new plugin. My best guess is that, right now, it would take a restart... which is not bad, but not ideal either.
In order to dynamically add a plugin at runtime, it seems like I would need
1) a way to get a new egg loaded
require(), or working_set.add()
2) a notification to go out to the parts of the code that care about the entry points for a particular name or group.
working_set.subscribe() adds a callback that will be invoked with a Distribution object whenever one is added to the working set. You can then call the distribution object's entry point introspection methods. Note that the function will be called for all distributions, including those that are already in the working set when you call subscribe(), so you shouldn't iterate over the existing entry points if you're going to use subscribe. Just subscribe, and your callback will get invoked for everything, as if it had been there before anything was added.
Does anyone else care about being able to add plugins without a restart, or is it just me?
Adding plugins without a restart isn't a problem. It's removing or upgrading them that's not practical.
On 8/30/05, Phillip J. Eby
At 07:07 AM 8/30/2005 -0400, Kevin Dangoor wrote:
I'm planning to use the EntryPoint facility for plugins in my application, and I was just thinking about what it would take to load a new plugin. My best guess is that, right now, it would take a restart... which is not bad, but not ideal either.
In order to dynamically add a plugin at runtime, it seems like I would need
1) a way to get a new egg loaded
require(), or working_set.add()
2) a notification to go out to the parts of the code that care about the entry points for a particular name or group.
working_set.subscribe() adds a callback that will be invoked with a Distribution object whenever one is added to the working set.
Thanks, Phillip! I'm not surprised to hear that you've already worked this out!
Does anyone else care about being able to add plugins without a restart, or is it just me?
Adding plugins without a restart isn't a problem. It's removing or upgrading them that's not practical.
Yeah, I've been using Python long enough to know about the intracacies of trying to reload something. That's a less critical use case than being able to add something seamlessly. Kevin
participants (2)
-
Kevin Dangoor
-
Phillip J. Eby