Discussion:
[comtypes-users] REGCLS_MULTIPLEUSE not working for local servers on Windows 8?
Alicia Chen
2013-03-15 22:49:59 UTC
Permalink
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] 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
Alicia Chen
2013-03-18 23:12:36 UTC
Permalink
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
Post by Alicia Chen
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.
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
Creating MyObject object now!
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] 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
Thomas Heller
2013-03-19 07:44:39 UTC
Permalink
Post by 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
Post by Alicia Chen
On Fri, Mar 15, 2013 at 3:49 PM, Alicia Chen
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.
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,
Creating MyObject object now!
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
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
comtypes-users mailing list
https://lists.sourceforge.net/lists/listinfo/comtypes-users
Alicia Chen
2013-03-19 19:57:13 UTC
Permalink
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
Post by Thomas Heller
Post by 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
Post by Alicia Chen
On Fri, Mar 15, 2013 at 3:49 PM, Alicia Chen
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.
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,
Creating MyObject object now!
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?
Post by Alicia Chen
--Alicia
------------------------------------------------------------------------------
Post by Alicia Chen
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
comtypes-users mailing list
https://lists.sourceforge.net/lists/listinfo/comtypes-users
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
comtypes-users mailing list
https://lists.sourceforge.net/lists/listinfo/comtypes-users
Loading...