[python-win32] Apache & mod_python & win32com

Mark Hammond mhammond at skippinet.com.au
Mon Apr 28 08:38:52 CEST 2008


> The problem with apache tho is, that it starts the thread itself and I
> don't know wether my script runs on a new thread or not.

Yeah - it sucks if there is no way to hook thread creation.

> I did some
> testing with calling CoInitialize at the start of my scripts and
> CoUnitialize at the end of my script (as suggested by others before)
> and it seemed to work...

Yes, it will work - it's just slightly slower as it doesn't *need* to be
done each time.

> Do I understand you correct, that you suggest to use CoInitializeEx
> instead? My scripts should all use the aparment threading model tho,
> but I can try and change to CoInitializeEx =)

See the docs for the functions - CoInitializeEx lets you specify the
threading model, CoInitialize() implies it.  If you must use apartment
threading, then that is fine, and you can use either function to do that
(but if you did not need to use it, you may have found free-threading
performs better in some cases when multiple threads are running
concurrently)

> So for the DOM document there seem to be either version, but for the
> schema and template objects I don't know wether these are free-threaded
> or not and wether that matters at all... :-/ I have to admit that the
> whole COM stuff is a bit mysterious for me...

Yeah, it is confusing and can generally be ignored if you aren't sharing COM
objects between threads etc - ie, just stick with what works ;)

Mark




More information about the python-win32 mailing list