Hi, I have a problem with thread and win32com.client running python 2.5 on vista (activestate python)
import win32com.client, thread def child(test): problem=win32com.client.Dispatch("WScript.Shell") print 'hello from thread', test def parent(): i=0 while 1: i+=1 thread.start_new(child,('abc',)) if raw_input()=='q': break parent() above codes will give me error when I run it. but if without the line problem=win32com.client.Dispatch("WScript.Shell") it just works fine. errors are: Unhandled exception in thread started by <function child at 0x01E690F0> Traceback (most recent call last): File "C:\Users\Test\Desktop\Test\test_thread.py", line 3, in child problem=win32com.client.Dispatch("WScript.Shell") File "C:\Python25\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch dispatch, userName = dynamic._GetGoodDispatchAndUserName (dispatch,userName,clsctx) File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147221008, 'CoInitialize has not been called.', None, None) Traceback (most recent call last): File "C:\Users\Test\Desktop\Test\test_thread.py", line 11, in <module> parent() File "C:\Users\Test\Desktop\Test\test_thread.py", line 10, in parent if raw_input()=='q': break Thanks for any help. -- http://mail.python.org/mailman/listinfo/python-list