COM and threading, "CoInitialize"?
Ferdinand Sousa
ferdinandsousa at gmail.com
Tue Feb 10 08:22:24 EST 2009
Greetings to list members,
I am trying to use an Acrobat COM object in a class that is subclassed from
threading.Thread.
Since threading.Thread is subclassed, the __init__ method of the inheriting
class must explicitly call the threading.Thread.__init__ method of the
parent. I guess I'm missing something similar for the COM object. Threading
code and traceback below. Any pointers?
CODE:
=================================
class process_file(threading.Thread):
def __init__(self,connection):
threading.Thread.__init__(self)
self.connection=connection
def run(self):
####
irrelevant code here
####
# Acrobat COM starts
AVD = win32com.client.Dispatch('AcroExch.AVDoc') # Traceback
refers to this line (89)
pdfname=pdfname.replace('.pdf',PDFNAME_SUFFIX)
AVD.Open(pdf.name, pdfname) # ////////
print 'opened avdoc'
==================================
TRACEBACK:
==================================
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python25\lib\threading.py", line 486, in __bootstrap_inner
self.run()
File "D:\Ferdinand\#Storage\Ferdi-python\Acrobat Automation\temp
testing.py", line 89, in run
AVD = win32com.client.Dispatch('AcroExch.AVDoc')
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 has not been called.', None, None)
==================================
TIA. Best regards,
Ferdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090210/ff083b42/attachment.html>
More information about the Python-list
mailing list