[triangle-zpug] Using COM in threads

Lee Nelson lee_nelson at ncsu.edu
Mon Feb 18 18:07:04 UTC 2008

I am still trying to learn Python and I am currently trying to troubleshoot
the following error:


Unhandled exception in thread started by <function get_data_thread at


Traceback (most recent call last):

  File "CFL_Daq.py", line 224, in get_data_thread

    data_response = scan2.GetReducedDataString(data_string)

  File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 496,


    raise AttributeError, "%s.%s" % (self._username_, attr)

AttributeError: StrainSmart.SSDataConnection2.GetReducedDataString


I think this is related to my use of a COM object inside of a thread.
According to this example
I tried importing the pythoncom module and adding the following lines to the
definition of my thread function:


sys.coinit_flags = 0







But I'm still getting the same error.  I have no trouble using this COM
object outside of threads.  Does anybody have any suggestions as to what I'm
doing wrong?  I don't really understand the reason for the sys.coinit_flags
or the CoInitialize() function so any resources that better explain the use
of COM objects in threads could also be useful.






Entire project can be downloaded here:



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://starship.python.net/pipermail/triangle-zpug/attachments/20080218/93955be4/attachment.htm 

More information about the triangle-zpug mailing list