[triangle-zpug] Using COM in threads
David Handy
david at handysoftware.com
Mon Feb 18 19:36:18 UTC 2008
The website you googled is a red herring. Your error has nothing to do with
threads.
When you get an error like this:
AttributeError: StrainSmart.SSDataConnection2.GetReducedDataString
it means there is no such method as GetReducedDataString.
David H
On Mon, Feb 18, 2008 at 01:07:04PM -0500, Lee Nelson wrote:
> 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
> 0x00C27EB0
>
> >
>
> 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,
> in
>
> __getattr__
>
> 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
> (http://devnulled.com/content/2004/01/com-objects-and-threading-in-python/),
> I tried importing the pythoncom module and adding the following lines to the
> definition of my thread function:
>
>
>
> sys.coinit_flags = 0
>
> pythoncom.CoInitialize()
>
> .
>
> .
>
> .
>
> Pythoncom.CoUninitialize()
>
>
>
> 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.
>
>
>
> Thanks,
>
>
>
> Lee
>
>
>
> Entire project can be downloaded here:
> http://www.ce.ncsu.edu/centers/cfl/temp/CFL_Daq.py
>
>
>
>
>
> _______________________________________________
> triangle-zpug mailing list
> triangle-zpug at starship.python.net
> http://starship.python.net/mailman/listinfo/triangle-zpug
--
David Handy
Computer Programming is Fun!
Beginning Computer Programming with Python
http://www.handysoftware.com/cpif/
More information about the triangle-zpug
mailing list