[Distutils] listening for EntryPoints

Phillip J. Eby pje at telecommunity.com
Tue Aug 30 17:15:55 CEST 2005

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.

More information about the Distutils-SIG mailing list