468,294 Members | 1,830 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,294 developers. It's quick & easy.

Problem with COM and threads -- urgent

HI all,

I have a problem in accesing COM objects in threads. To be precise,
lets assume that I have a class GenericFunctions which is defined as
follows:


import win32com.client, pythoncom, thread
ie=win32com.client.Dispatch('internetexplorer.appl ication')
ie.Visible=1


class GenericFunctions:


def __init__(self):
print "In Constructor of Generic Functions"


def MyNavigate(self,dest):
ie.Navigate(dest)


Now there is another file Main.py which is defined as follows:


import win32com.client, pythoncom, thread
from GenericFunctions import *
obj = GenericFunctions()


class Mainclass:
def __init__(self);
print "In Constructor of Main class"


def threadFunction(self,dest):
pythoncom.CoInitialize()
d=pythoncom.CoGetInterfaceAndReleaseStream(s,
pythoncom.IID_IDispatch)
my_ie=win32com.client.Dispatch(d)
obj.func(dest) # this is gving an error.
pythoncom.CoUninitialize()


if __name__ == "__main__":


s=pythoncom.CoMarshalInterThreadInterfaceInStream( pythoncom.IID_IDispatch,i*e)
thread.start_new_thread(self.nav, (s,'www.google.com')


Basically, I want to access object of GenericFunctions class inside
threadFunction(). However I was able to execute
my_ie.Navigate("google.com"). But that was not I wanted. I am not
knowing where the error is....
Please let me know the solution ASAP...


Teja.P
Oct 17 '06 #1
1 1077
bartonc
6,596 Expert 4TB
obj = GenericFunctions()
obj.func(dest) # this is gving an error.
Teja.P
do mean:

obj.MyNavigate(dest)

?
Oct 17 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Sachin Jagtap | last post: by
34 posts views Thread by Kovan Akrei | last post: by
28 posts views Thread by Tamir Khason | last post: by
6 posts views Thread by Carlos Lozano | last post: by
reply views Thread by Mamatha | last post: by
4 posts views Thread by Adrian Parker | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.