Singleton COM local/remote server?

Alex Martelli alex at magenta.com
Wed Jul 5 07:14:41 EDT 2000


John Lull <lull at acm.org> wrote in message
news:7bd5msssk48km280t9bvds4i3v6hs7r8or at 4ax.com...
> I'm prototyping a DCOM server in Python.  The server coordinates
    [snip]
> Since each port can belong to at most one server, I cannot have
> multiple servers on the same machine.  I can't figure out how to
> ensure there is only *one* copy of the server started, regardless of
> how many clients want to use it.
>
> Any samples, pointers to documentation, key phrases to search MSDN
> for, etc. would be *greatly* appreciated.

I'm not sure how this translates to Python's implementation
of COM, but, at a lower abstraction level, this is exactly
what is accomplished by passing the REGCLS_MULTIPLEUSE value
as the "flags" parameter in the CoRegisterClassObject calls
that an .EXE does, at startup, to let the Service Control
Manager of COM know about its class-objects (IClassFactory
instances).

When such a call is made, and, later, another instance of
the object is required, the SCM won't start another process,
but rather re-use the class-factory it knows is already
active (and which, it has been informed, is OK for multiple
use).  You can take further precautions to check that this
is indeed working as designed, but they should not be needed.

Now, there remains the issue of, how to control the flags
used on CoRegisterClassObject by pythonw.exe...?  I can't
find it in the docs (which doesn't mean it isn't there...
it just says I can't find it).  Maybe we need to look at
the sources...?


Alex






More information about the Python-list mailing list