Trying to get IE to quit inside of a thread. If I navigate to google.com or facebook.com it has no problem, the ie.Quit()
works just fine. However, when I navigate to our company sharepoint site I get:
Error in IEThread: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147467259), None
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\python27\lib\threading.py", line 808, in __bootstrap_inner
self.run()
File "PepTalk.pyw", line 404, in run
ie.Quit()
File "C:\python27\lib\site-packages\win32com\client\dynamic.py", line 522, in __getattr__
raise AttributeError("%s.%s" % (self._username_, attr))
AttributeError: InternetExplorer.Application.Quit
It doesn't make any sense because the AttributeError is for something that I can make the same script do with a different address. I'm running IE in it's own thread, here is my code:
class IEThread(Thread):
def __init__(self):
Thread.__init__(self)
self.queue = Queue()
def run(self):
ie = None
pythoncom.CoInitialize()
try:
ie = Dispatch('InternetExplorer.Application')
ie.Visible = 1
url = self.queue.get()
print 'Visiting...', url
ie.Navigate(url)
while ie.Busy:
time.sleep(0.1)
except Exception, e:
print "Error in IEThread: ", e
if ie is not None:
ie.Quit()
ieThread = IEThread()
ieThread.start()
url = 'https://company.sharepoint.com/company/Shared Documents/Weekly Pep Talk/2013/'
ieThread.queue.put(url)
Any ideas why this would be happening?