<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'><div style="text-align: left;">Hi,<br><br>first of all, just import pythoncom directly<br>&lt;code&gt;<br>import pythoncom<br>&lt;/code&gt;<br><br>As far as where to put pythoncom.CoInitialize() I'm not certain but i think at the top (or start) of your whole application.. if it's threaded then call it for each thread (at the start)<br>"Initializes the COM library on the current thread and identifies the
concurrency model as single-thread apartment (STA). Applications must
initialize the COM library before they can call COM library functions ..."<br>from: http://msdn2.microsoft.com/en-us/library/ms678543(VS.85).aspx<br></div><br>Hope that helps,<br>Alex<br><br><hr id="stopSpelling">&gt; From: Dominique.Holzwarth@ch.delarue.com<br>&gt; To: python-win32@python.org<br>&gt; Date: Thu, 24 Apr 2008 16:15:17 +0100<br>&gt; Subject: [python-win32] Apache &amp; mod_python &amp; win32com<br>&gt; <br>&gt; Hello everyone<br>&gt; <br>&gt; I'm developing a web application using mod_python and the apache web server. That application has to handle xml files and for that I'm using win32com with with MSXML.<br>&gt; <br>&gt; My problem is, that apache spawns a new process / thread (not sure wether ist a process or thread. I think it's a thread) per http request. So when multiple users generated requests "at the same time" (new request before the first one is returned) I have multiple threads running. And that's where my win32com code is crashing...<br>&gt; <br>&gt; Currently, for every request my code does the following (as an example):<br>&gt; <br>&gt; return win32com.client.Dispatch("Msxml2.DOMDocument.6.0")<br>&gt; <br>&gt; To get an empty MSXSML DOM object.<br>&gt; <br>&gt; For multiple requests at the same time I get the following error:<br>&gt; <br>&gt;  File "C:\Program Files\Apache Software Foundation\Apache2.2\TCRExceptionManagerData\database_library\database.py", line 24, in __init__<br>&gt;     self.__configFileSchema = self.__XSDSchemaCache()<br>&gt; <br>&gt;   File "C:\Program Files\Apache Software Foundation\Apache2.2\TCRExceptionManagerData\database_library\database.py", line 1774, in __XSDSchemaCache<br>&gt;     return win32com.client.Dispatch("MSXML2.XMLSchemaCache.6.0")<br>&gt; <br>&gt;   File "C:\Program Files\Python25\lib\site-packages\win32com\client\__init__.py", line 95, in Dispatch<br>&gt;     dispatch, userName = dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)<br>&gt; <br>&gt;   File "C:\Program Files\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName<br>&gt;     return (_GetGoodDispatch(IDispatch, clsctx), userName)<br>&gt; <br>&gt;   File "C:\Program Files\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch<br>&gt;     IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch)<br>&gt; <br>&gt; com_error: (-2147221008, 'CoInitialize has not been called.', None, None)<br>&gt; <br>&gt; I've read already a bit in this mailing list and someone mentioned that one need to call pythoncom.CoInitialize() and pythoncom.CoUninitialize(). But I don't know where exactly i should call those functions and wether that'll solve my problem... Also, when I do a 'import win32com.pythoncom' I get an error that the module 'pythoncom' does not exist!<br>&gt; <br>&gt; I would be really happy if someone could help me and tell me how to make my win32com work for multiple threads!<br>&gt; <br>&gt; Greetings<br>&gt; Dominique<br>&gt; <br>&gt; _______________________________________________<br>&gt; python-win32 mailing list<br>&gt; python-win32@python.org<br>&gt; http://mail.python.org/mailman/listinfo/python-win32<br><br /><hr />Get 5GB  of online storage for free! <a href='http://skydrive.live.com/' target='_new'>Get it Now! </a></body>
</html>