[pywin32-bugs] [ pywin32-Bugs-2909712 ] win32com.client.Dispatch fails if called in thread
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2009-12-06 18:29:21
|
Bugs item #2909712, was opened at 2009-12-06 19:29 Message generated for change (Tracker Item Submitted) made by kahlbutz You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=2909712&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Klaus Noekel (kahlbutz) Assigned to: Nobody/Anonymous (nobody) Summary: win32com.client.Dispatch fails if called in thread Initial Comment: I would like to create COM objects via win32com.client.Dispatch in several threads to take advantage of multithreading. However, the same call that succeeds in the main thread fails when executed within a worker thread. The error message is: Exception in thread Thread-3: Traceback (most recent call last): File "C:\Python25\Lib\threading.py", line 486, in __bootstrap_inner self.run() File "C:\daten\PTV\Visum Misc\threadtest.py", line 12, in run XL = win32com.client.Dispatch("Excel.Application") # this one fails 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) com_error: (-2147221008, 'CoInitialize wurde nicht aufgerufen.', None, None) The last line translates as "CoInitialize was not called". Why can't I create COM objects from worker threads? Or what do I have to do to make it work? Thanks for any advice! Klaus ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551954&aid=2909712&group_id=78018 |