Note that there are some explanatory texts on larger screens.

plurals
  1. POpython, COM and multithreading issue
    text
    copied!<p>I'm trying to take a look at IE's DOM from a separate thread that dispatched IE, and for some properties I'm getting a "no such interface supported" error. I managed to reduce the problem to this script:</p> <pre class="lang-python prettyprint-override"><code>import threading, time import pythoncom from win32com.client import Dispatch, gencache gencache.EnsureModule('{3050F1C5-98B5-11CF-BB82-00AA00BDCE0B}', 0, 4, 0) # MSHTML def main(): pythoncom.CoInitializeEx(0) ie = Dispatch('InternetExplorer.Application') ie.Visible = True ie.Navigate('http://www.Rhodia-ecommerce.com/') while ie.Busy: time.sleep(1) def printframes(): pythoncom.CoInitializeEx(0) document = ie.Document frames = document.getElementsByTagName(u'frame') for frame in frames: obj = frame.contentWindow thr = threading.Thread(target=printframes) thr.start() thr.join() if __name__ == '__main__': thr = threading.Thread(target=main) thr.start() thr.join() </code></pre> <p>Everything is fine until the <code>frame.contentWindow</code>. Then bam:</p> <pre><code>Exception in thread Thread-2: Traceback (most recent call last): File "C:\python22\lib\threading.py", line 414, in __bootstrap self.run() File "C:\python22\lib\threading.py", line 402, in run apply(self.__target, self.__args, self.__kwargs) File "testie.py", line 42, in printframes obj = frame.contentWindow File "C:\python22\lib\site-packages\win32com\client\__init__.py", line 455, in __getattr__ return self._ApplyTypes_(*args) File "C:\python22\lib\site-packages\win32com\client\__init__.py", line 446, in _ApplyTypes_ return self._get_good_object_( com_error: (-2147467262, 'No such interface supported', None, None) </code></pre> <p>Any hint ?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload