I am having a very difficult time enforcing a single running instance
of a COM server and am hoping that someone out there might have a
suggestion.  The basic scenario is that we have a COM server (created
with the assistance of  win32com.server) which needs to perform a
somewhat laborious data loading process when started.  The problem is
that a dll which makes calls to this COM server was spawning off a new
server every time it called in a query.  We eliminated part of the
crushing burden of constantly spawned COM server instances by moving
the heavy lifting into a singleton (the simple module-level singleton
pattern) and having each COM server attach to this singleton.  This
solved our first problem with the start-up load but we still end up
with way to many instances of our proxy to this singleton being
created and wanted to figure out a way to make sure that only a single
instance of this proxy was created.

So,l first tried using the standard CreateMutex recipe to ensure that
only one instance of the COM server would be created.  Unfortunately
this particular process works fine when I run a test script from the
command line but the COM server is able to blow right by any attempts
to use the mutex to limit the number of copies that are running.

Next up was an attempt to create a lockfile.  Same end-result, nothing
seemed to stop the COM servers from each grabbing what was thought to
be an exclusive lock.

At this point I have run out of ideas.  Does anyone have a suggestion
of how to create a COM server in Python that can ensure that only a
single instance of the COM server is running?

Regards,

Jim
_______________________________________________
Python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to