Sufficient conditions for COM local server to be singleton

Gordon McMillan gmcm at
Wed Jun 20 22:31:31 CEST 2001

Bill Bell wrote: 

>My essential question is: I had understood from reading previous 
>discussions on this list that, by default, to make a COM local 
>server fire up in only a single copy it is only necessary to declare 
>"_reg_clsctx_ = pythoncom.CLSCTX_LOCAL_SERVER". However, 
>this doesn't seem to do the trick.

No, not quite. Using CLSCTX_LOCAL_SERVER is enough to ensure
that there's only a single copy of your module loaded. If you
want only one copy of your instance, you'll have to use a
singleton pattern. Try registering a ParentFactory class that does
nothing but return the one and only instance of Parent (wrapped, 
of course).

class ParentFactory:
  _public_methods_ = ["GetTheParent"]
  _reg_clsid_ = ....

- Gordon

More information about the Python-list mailing list