I have a tentative alternate solution.

We're using the out-of-proc server in a slightly non-standard way. Normally
it would get launched when someone attempts to create an object it
implements, and then server.localserver.run() will exit when the last
reference count to the last object is released, causing the server to go
away. Ours is actually a process that's supposed to be running all the time
(although it has some UI so it's not a service), so the behavior of exiting
the message loop when the last object is released is bad for us. I used to
get around this by just calling localserver.run() in a while loop, but in
Windows 8 with comtypes this is not working. Instead of letting it exit and
calling it in a loop, I'm just going to create an object and hold a
reference to it myself so the loop doesn't exit.

If anyone is interested in figuring out why calling run() multiple times in
the same process is not working, the C++ sample code (VS 2008) that does
more or less the same thing (except that it works) is
here<https://www.dropbox.com/s/5znm5p6c7mgzabw/SampleCOMstuff.zip>
.


--Alicia


On Tue, Mar 19, 2013 at 12:44 AM, Thomas Heller <thel...@ctypes.org> wrote:

> Am 19.03.2013 00:12, schrieb Alicia Chen:
> > I tried a similar setup with a sample C++ server/client and it works
> > fine. I haven't yet managed to determine what the differences are. Can
> > anyone shed some light on this?
> >
>
> Alicia,
>
> I have not yet used comtypes on Windows 8.  Currently downloading win8
> from my MSDN subscription...
>
> Thomas
> >
> > On Fri, Mar 15, 2013 at 3:49 PM, Alicia Chen
> > <owlishn...@gmail.com
> > <mailto:owlishn...@gmail.com>> wrote:
> >
> >     We pass REGCLS_MULTIPLEUSE as the flag for an out-of-proc server.
> >     This worked fine on Windows 7, but Windows 8 seems to ignore this
> >     flag and attempts to launch a new instance for any call other than
> >     the first.
> >
> >     I tested this with the sample code given here
> >     <http://starship.python.net/crew/theller/comtypes/server.html> with
> >     only a slight modification, changing the server so that it stays
> >     running and continually processes calls, to emulate what our program
> >     does.
> >
> >                      while True:
> >                          comtypes.server.localserver.run([MyObjectImpl])
> >
> >     On Win7, if you launch the server, you can run the client multiple
> >     times and the calls will always go to the running instance of the
> >     server. On Win8, the first client call behaves as expected, but all
> >     subsequent calls cause a new instance of the server to be launched,
> >     and CreateObject eventually fails with the following error:
> >
> >     Creating MyObject object now!
> >     Traceback (most recent call last):
> >        File "tools\sample_com_obj\sample_client.py", line 13, in <module>
> >          x = CreateObject("MyTypelib.MyObject")
> >        File "\comtypes\client\__init__.py", line 235, in CreateObject
> >          obj = comtypes.CoCreateInstance(clsid, clsctx=clsctx,
> >     interface=interface)
> >        File "\comtypes\__init__.py", line 1145, in CoCreateInstance
> >          _ole32.CoCreateInstance(byref(clsid), punkouter, clsctx,
> >     byref(iid), byref(p))
> >        File "_ctypes/callproc.c", line 936, in GetResult
> >     WindowsError: [Error -2146959355 <tel:2146959355>] Server execution
> >     failed
> >
> >     (That error number is 0x80080005 for marginally more readability)
> >
> >     Both server and client files attached for your reference.
> >
> >     Is anyone else experiencing this? Am I doing something horribly
> wrong?
> >
> >     --Alicia
> >
> >
> >
> >
> >
> ------------------------------------------------------------------------------
> > Everyone hates slow websites. So do we.
> > Make your web apps faster with AppDynamics
> > Download AppDynamics Lite for free today:
> > http://p.sf.net/sfu/appdyn_d2d_mar
> >
> >
> >
> > _______________________________________________
> > comtypes-users mailing list
> > comtypes-users@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/comtypes-users
> >
>
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_mar
> _______________________________________________
> comtypes-users mailing list
> comtypes-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/comtypes-users
>
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to