You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

62 lines
2.3 KiB

From: htrd90 at zepler.org (Toby Dickenson)
Date: Thu, 08 Apr 1999 20:38:00 GMT
Subject: COM Event Sinks and Connection Points in Python
References: <7eggfh$o0f$1@nnrp1.dejanews.com> <7egnl2$ca5$1@m2.c2.telstra-mm.net.au>
Message-ID: <3711134d.17632096@news.freeserve.net>
Content-Length: 2025
X-UID: 323
(posted, and copied to Mark)
"Mark Hammond" <MHammond at skippinet.com.au> wrote:
>
>cingram at my-dejanews.com wrote in message
><7eggfh$o0f$1 at nnrp1.dejanews.com>...
>>I am trying to use functionality from a DLL that requires me to create a
>COM
>>event sink so that it can call back with events. I am trying to write this
>>event sink in Python. However, when I try to create a SimpleConnection
>>object, it gives this exception: "Unable to open the access token of the
>>current thread".
>
>There appears to be some problem using connection points from Python.exe.
>Some objects - mainly OCX controls - only fire event when running inside
>Pythonwin as an OCX.
For controls this is to be expected. They are allowed to be fairly
non-functional until activated, which requires a control site. They might
implement IDispatch, but they can not be used a 'just' an automation server.
>The "threading bug" I mention isnt the same as this. The threading bug will
>actually cause Python to die completely with an access violation. I am
>fairly certain they are not related.
I read that comment a while ago, and Ive been meaning to investigate since then.
Well, my next project will be using events, and this post reminded me, so I
thought I would take a look.
If I remove the extra 'return' from testPyComTest.py then I always get a
Fatal Python error: PyThreadState_Get: no current thread
Is this the bug you mean? I think I have some answers....
I believe this problem is not caused by a bug in pythoncom, but by several bugs
in PyCOMTest, the C++ server that complements this test harness.
In PyCOMImpl.cpp, line 49, a new thread is started. That thread uses the Fire
method of the CPyCOMTest object, however this breaks the COM apartment rules. To
pass an object reference across apartments you need to use
CoMarshalInterThreadInterfaceInStream, at least once.
Secondly, the new thread does not call CoInitializeEx.
Hopefully I will have time to dig further next week.
I hope this helps,
Toby Dickenson