BaseHTTPServer, ThreadingMixIn and COM.

Arpad Kiss sekter at matavnet.hu
Tue Mar 14 10:03:52 EST 2000


Hi,
It is needed by the COM infrastructure. When you don't use threads this
function call is needed too, but it is done by Python automatically.
In a new thread before any COM call you have to call CoIniztialize. If I am
right multiply CoInitialize call in the same thread doesn't cause any harm.
So putting these lines before
'ExcelApp=win32com.client.Dispatch("Excel.Application")'  may help:
import pythoncom
pythoncom.CoInitialize()
I'm not familiar BaseHTTPServer and ThreadingMixin, maybe there is better
place to put these lines.
This is not Python specific. Look it up in COM docs/books.
Best Regards,
Arpad

----- Original Message -----
From: Paul Robinson <paul.robinson at quantisci.co.uk>
To: Arpad Kiss <sekter at matavnet.hu>
Cc: <python-list at python.org>
Sent: Tuesday, March 14, 2000 3:23 PM
Subject: Re: BaseHTTPServer, ThreadingMixIn and COM.


> Arpad Kiss wrote:
> >
> > Hi,
> > The answer is in the error message you got: pywintypes.com_error:
> > (-2147221008, 'CoInitialize has not been called.', None, None)
> > You have to call CoInitialize in every threads before you use any other
COM
> > functionality.
>
> Can you expand on this slightly...
> Like, why, where, when...?
>
> And also, now that I have it running (kind of - I can make multiple
> requests - just not simultaneously), it appears that the object
> referenced by ExcelApp is the same object in both threads. Not being a
> COM expert I don't know whether this is a feature of the object or a bug
> in my code.
>
> Thanks,
> Paul
>
> -----------------------------------
> Business Collaborator Team
> Enviros Software Solutions
> http://www.businesscollaborator.com
> -----------------------------------
>





More information about the Python-list mailing list