threading and internet explorer com
Stefan Schukat
SSchukat at dspace.de
Fri Jan 28 07:45:06 EST 2005
... and pythoncom.CoUninitialize()
My preferred way is:
def run():
pythoncom.CoInitialize()
try:
ie =
win32com.client.Dispatch('InternetExplorer.Application.1')
finally:
# Trigger the release of the object since after
CoUninitialize
# it could not be reached
ie = None
pythoncom.CoUninitialize()
Stefan
> -----Original Message-----
> From: python-list-bounces+sschukat=dspace.de at python.org
> [mailto:python-list-bounces+sschukat=dspace.de at python.org]On Behalf Of
> Roger Upole
> Sent: Friday, January 28, 2005 7:29 AM
> To: python-list at python.org
> Subject: Re: threading and internet explorer com
>
>
> You'll need to call pythoncom.CoInitialize() in each thread.
>
> Roger
>
> "James" <c00lways at gmail.com> wrote in message
> news:41f9777f_2 at news.tm.net.my...
> > 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
>
>
>
>
> ----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure
> Usenet News==----
> http://www.newsfeeds.com The #1 Newsgroup Service in the
> World! >100,000 Newsgroups
> ---= East/West-Coast Server Farms - Total Privacy via Encryption =---
> --
> http://mail.python.org/mailman/listinfo/python-list
>
More information about the Python-list
mailing list