Python COM server running as a singleton
Gordon McMillan
gmcm at hypernet.com
Thu Jan 17 15:47:19 EST 2002
Marc ENGEL wrote:
> I want to be able to get a COM server written in Python running as a
> singleton. I also want to Dispatch it from VB and from Python and to
> get the same instance.
[snip]
> Here is a solution I found using GetActiveObject.
[snip]
You've probably gone to too much work :-(. At least, here's
what I've found (which may well have holes in it):
If you use CLSCTX_LOCAL_SERVER, then COM will only start
one copy of your script. Each process using it will
(normally) get a fresh *instance* of your COM class, but
that fairly easy to get around. You could probably even
use Alex's borg pattern.
To be non-tricky about it, write (and register) a COM class
that has one exposed method. That method returns a module
global instance of the class you're really interested in
(creating it if need be). You'll need to Wrap it, of course.
-- Gordon
http://www.mcmillan-inc.com/
More information about the Python-list
mailing list