threading and internet explorer com

J

James

hi,

i'm using python 2.4 with pywin32...
I've tried to use internet explorer control with a class.
it was fine until i decided to inherit thread for the class...

class domain01(threading.Thread):
def __init__(self):
#blabla
threading.Thread.__init__(self)

def run(self):
self.ie = win32com.client.Dispatch('InternetExplorer.Application.1')
#this line gives error if i use .start(), but if i use .run.. no error...
self.ie.Visibble = 1
print "running"



xyz = domain()
xyz.start()

===========
this is what i get:
Exception in thread Thread-23:
Traceback (most recent call last):
File "C:\Python24\lib\threading.py", line 442, in __bootstrap
self.run()
File "C:\python2exe\domain01.py", line 41, in run
self.dologin()
File "C:\python2exe\domain01.py", line 56, in dologin
self.ie=win32com.client.Dispatch('InternetExplorer.Application.1')
File "C:\Python24\Lib\site-packages\win32com\client\__init__.py",
line 95, in Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
91, in _GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Python24\Lib\site-packages\win32com\client\dynamic.py", line
79, in _GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147221008, 'CoInitialize has not been called.', None, None)



=====
but if i run:
xyz = domain()
xyz.run()

##no error! it's weird....

anyone know how to solve this problem?

thank you :)

best regards,

James
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,480
Members
44,900
Latest member
Nell636132

Latest Threads

Top