I can’t see how this class is used, but it is slightly suspect, in the fact
it stores the result of the unmarshal in ‘self.fmProject’ – but there is
nothing to prevent other threads from using self.fmProject, which would be
an error.  Unless something not shown prevents this happening, you need to
avoid storing the result of the unmarshal anywhere than in variables local
to a function and passed around as a param (or maybe using something like
threading.local() to help with this.

 

Mark

 

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of mauro tizianel
Sent: Thursday, 21 February 2008 2:48 AM
To: python-win32@python.org
Subject: [python-win32] Help with COM objs across threads: The object
exporter specified was not found

 

Dear list,

I wrote a small class which has some COM objects among its attributes. I
need to access the object from different threads so I defined two methods to
marshal and unmarshal the interfaces when working with the object.
Everything seemed to work fine on my PC, never had an error.
But I distributed the module to a user and I have been told that after a few
threads successfully exiting (can be two or hundreds...) something goes
wrong in "unMarshal" and Exception occurred ((-2147022986, 'Der angegebene
Objektexporter wurde nicht gefunden.', None, None)) is reported (it took me
a while to figure out that this is: 0x00000776 - 1910 The object exporter
specified was not found).
Then, but that's obvious, I get Exception occurred ((-2147417827, 'Das
Schnittstellendatenpaket (Marshall/OBJREF) hat ein ungültiges oder
unbekanntes Format.', None, None)) when I try to marshal (unknown or invalid
format).

Since I cannot reproduce the exception I was not able neither to locate
exactly where the exception occurs, nor to find the reason (the only
difference is that I am administrator on my machine and he is not).

Before modifying the code to deal with the exception, (here's the request
for help) I would need help to figure out if I am doing things the wrong way
with threads (I am new to COM and not a software developer) or such
exceptions 'just occurs sometimes'.

Thanks,

Mauro

<code>
class AppInterface(object):
    def __init__(self):
        self.fmApp = win32com.client.Dispatch("Whatever.Application")
        self.fmProject = self.fmApp.Project("Newproject")
    def marshal(self):
        self.fmAppStream =
pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,
self.fmApp._oleobj_)
        self.fmProjectStream =
pythoncom.CoMarshalInterThreadInterfaceInStream(pythoncom.IID_IDispatch,
self.fmProject._oleobj_)
    def unMarshal(self):
        idispatch =
pythoncom.CoGetInterfaceAndReleaseStream(self.fmAppStream,
pythoncom.IID_IDispatch)
        self.fmApp = win32com.client.Dispatch(idispatch)
        idispatch =
pythoncom.CoGetInterfaceAndReleaseStream(self.fmProjectStream,
pythoncom.IID_IDispatch)
        self.fmProject = win32com.client.Dispatch(idispatch)
</code> 

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to