Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > threading and internet explorer com

Reply
Thread Tools

threading and internet explorer com

 
 
James
Guest
Posts: n/a
 
      01-27-2005
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.Applica tion.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,userN ame,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
 
Reply With Quote
 
 
 
 
Roger Upole
Guest
Posts: n/a
 
      01-28-2005
You'll need to call pythoncom.CoInitialize() in each thread.

Roger

"James" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.Applica tion.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,userN ame,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 =---
 
Reply With Quote
 
 
 
 
James
Guest
Posts: n/a
 
      01-28-2005
thannnnk you Roger
thank you so much

best regards,

James

Roger Upole wrote:
> You'll need to call pythoncom.CoInitialize() in each thread.
>
> Roger
>
> "James" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>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.Applica tion.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,use rName,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 =---

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Internet Explorer 8: C:\Program Files\Internet Explorer\iexplore.exe vs C:\Program Files (x86)\Internet Explorer\iexplore.exe Nathan Sokalski Windows 64bit 16 02-22-2010 08:31 AM
internet explorer 7 - Internet Explorer cannot display the webpag sandy j Windows 64bit 0 05-02-2009 02:12 AM
Re: threading in PyQt vs threading in standard library Steven Woody Python 0 01-09-2009 07:48 AM
threading in PyQt vs threading in standard library Steven Woody Python 0 01-09-2009 07:15 AM
Cooperative threading preemptive threading - a bit confused failure_to@yahoo.co.uk Java 9 12-29-2007 01:10 AM



Advertisments