Python COM and Threads

Olaf Meding olafmeding at tds.net
Thu Oct 14 15:56:05 EDT 2004


Looks like Python can not make COM calls from a thread?  Here is the
error message I get: 'CoInitialize has not been called.'

Here is the code:

  import threading
  import win32com.client

  class Thread1(threading.Thread):
    def run(self): 
        print 'thread 1'
        userInterface = win32com.client.Dispatch('Excel.Application')	

  def main():
    t1 = Thread1()
    t1.start()

  if __name__ == '__main__':
    main()


Thanks much for your help on this.

Olaf



More information about the Python-list mailing list