Hello everyone
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.
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...
Currently, for every request my code does the following (as an example):
return win32com.client.Dispatch("Msxml2.DOMDocument.6.0")
To get an empty MSXSML DOM object.
For multiple requests at the same time I get the following error:
File "C:\Program Files\Apache Software
Foundation\Apache2.2\TCRExceptionManagerData\database_library\database.py",
line 24, in __init__
self.__configFileSchema = self.__XSDSchemaCache()
File "C:\Program Files\Apache Software
Foundation\Apache2.2\TCRExceptionManagerData\database_library\database.py",
line 1774, in __XSDSchemaCache
return win32com.client.Dispatch("MSXML2.XMLSchemaCache.6.0")
File "C:\Program
Files\Python25\lib\site-packages\win32com\client\__init__.py", line 95, in
Dispatch
dispatch, userName =
dynamic._GetGoodDispatchAndUserName(dispatch,userName,clsctx)
File "C:\Program
Files\Python25\lib\site-packages\win32com\client\dynamic.py", line 98, in
_GetGoodDispatchAndUserName
return (_GetGoodDispatch(IDispatch, clsctx), userName)
File "C:\Program
Files\Python25\lib\site-packages\win32com\client\dynamic.py", line 78, in
_GetGoodDispatch
IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
pythoncom.IID_IDispatch)
com_error: (-2147221008, 'CoInitialize has not been called.', None, None)
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!
I would be really happy if someone could help me and tell me how to make my
win32com work for multiple threads!
Greetings
Dominique
_______________________________________________
python-win32 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-win32