------------------sample code begin------------------------- import threading
import wmi def run(*args): c = wmi.WMI () memory=c.Win32_LogicalMemoryConfiguration()[0] info='Total Virtual Memory: '\ +str(int(memory.TotalVirtualMemory)/1024)\ +'MB' print info print "Begin run() in main thread" run() print "Begin run() in child thread" thread=threading.Thread(target=run) thread.start() ------------------sample code end--------------------------- ------------------debug info begin-------------------------- Begin run() in main thread Total Virtual Memory: 1375MB Begin run() in child thread Exception in thread Thread-1: Traceback (most recent call last): File "C:\my\Python24\lib\threading.py", line 444, in __bootstrap self.run() File "C:\my\Python24\lib\threading.py", line 424, in run self.__target(*self.__args, **self.__kwargs) File "F:\chen\code\SoftRepairer\script\test\test.py", line 6, in run c = wmi.WMI () File "C:\my\Python24\Lib\site-packages\wmi.py", line 971, in connect handle_com_error (error_info) File "C:\my\Python24\Lib\site-packages\wmi.py", line 219, in handle_com_error raise x_wmi, "\n".join (exception_string) x_wmi: -0x7ffbfe1c - Invalid syntax ------------------debug info end---------------------------- ------------------info I have found------------------------- exception raised at: file: Python24\Lib\site-packages\win32com\client\__init__.py line: 88 code: moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname) context: def Moniker(Pathname, clsctx = pythoncom.CLSCTX_ALL): """ Python friendly version of GetObject's moniker functionality. """ moniker, i, bindCtx = pythoncom.MkParseDisplayName(Pathname) dispatch = moniker.BindToObject(bindCtx, None, pythoncom.IID_IDispatch) return __WrapDispatch(dispatch, Pathname, clsctx = clsctx) I have compaired the 'Pathname' parameter between main thread and child thread when running, they are the same. -----------------------end---------------------------------- How can I solve the problem? Thanks -- http://mail.python.org/mailman/listinfo/python-list