Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > com wrapper and threads

Reply
Thread Tools

com wrapper and threads

 
 
mic
Guest
Posts: n/a
 
      02-04-2004
I'm playing with using COM object shared among different threads.
Unfortunately I've come into a problem - I don't know how to properly invoke
com object from external thread. Here comes simplified code I'd like to use:

class ComObjectWrapper:
#this class is by all means needed - of course it's code is much more
complicated than just simply wrapping the COM interface
def __init__(self):
self.ComObject = Dispatch(somecom)

def useCom(self, value):
self.ComObject.use(value)

class MainThread:
def __init__(self):
self.Object = ComObjectWrapper()

def runChildThread(self):
CThread = ChildThread(self)
CThread.start()

class ChildThread(Thread):
def __init__(self, parent):
self.Parent = parent

def run(self):
#This thread has to use some methods from ComObjectWrapper instance
and it's dispatched COM object
pythoncom.CoInitialize()
self.Parent.Object.UseCom() # <--- this generates error
pythoncom.CoUninitialize()

I was trying to use different combinations of sys.coinit_flags = 0 and
pythoncom.COINIT_MULTITHREADED but without success up till now. I've even
managed to send to child thread proper com reference by using stream
marshalling (as stated in "Python programming for win32"), but still I don't
want to use COM itself but its "wrapper" class. Any enlightening thoughts?

Michal


 
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
Trivial C11 threads.h wrapper (public domain) John Tsiombikas C Programming 37 12-15-2012 03:31 AM
[new to threads] threads with UI and loop Une bévue Ruby 0 06-14-2006 10:22 AM
TB View, Threads, Threads with unread The Invisible Man Firefox 1 03-20-2006 02:09 AM
Standard Threads vs Weightless Threads yoda Python 2 08-01-2005 09:12 PM
com wrapper and threads mic Python 0 02-04-2004 09:18 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57