[python-win32] problem accessing OPC clients from thread

Tim Roberts timr at probo.com
Tue Dec 4 02:37:49 CET 2007


Jeff Peery wrote:
>
>  
>
> If I have a multithreaded application but use COM objects only within
> the secondary thread is pythoncom.CoInitialize() still required?
>

Every thread that will use COM services has to have run CoInitialize at
some point.  Pythoncom will automatically do a CoInitalize, but only in
your main thread.  From those two statements, you can see the answer to
your question is YES.


> So if I understand correctly, I could go the route I’m headed, but my
> code might be simpler and more reliable if I setup an event handler
> for the DataChange event of the group (as Graham pointed out). If that
> is the case, where might I go to learn about how to set that up?
>

I'd Google for "pythoncom com event handling".  It looks like there are
some good hits there.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list