COM objects in threads

Markus von Ehr vonehr at ira.uka.de
Wed Feb 7 05:52:47 EST 2001


Thanx for all answers,

finally I could solve the problem using the 
  pythoncom.CoMarshalInterThreadInterfaceInStream
without the book (just kiddin Mark ;-) ), after having two beers
and taking a sharp look at the testMarshal.py program. The last 
problem was a repeated COM call in the Thread. It is only possible,
if CoUninitialize is omitted.

    try:
	pythoncom.CoInitialize()
	if first_ThreadCall == 1:
	    interp =
pythoncom.CoGetInterfaceAndReleaseStream(Globals.interpStream,
		pythoncom.IID_IDispatch)
	    interp = win32com.client.Dispatch(interp)
	    doc = interp.Document
	    mplayer = doc.body.children("MediaPlayer1").object
	    first_ThreadCall = 0
	        
	mplayer.FileName = "C:/Programme/Python/lightcontrol/null.wav"
	  
    except pythoncom.com_error, details:
        print "Pythoncomerror, ", details

The first time I thought the COM interface is the biggest shit in
the world but know I think it is quite a simple interface, when it
works. I'm just implementing my next COM interface using win32com.
But it's quite slow.

Markus.



More information about the Python-list mailing list