[python-win32] sys.path and PyWin32 scripting engine

Mark Hammond skippy.hammond at gmail.com
Wed Jul 21 05:07:35 CEST 2010


On 21/07/2010 2:45 AM, Tim Roberts wrote:
>   Marc-Andre Belzile wrote:
>> I'm referring to Python Active Scripting engines available in pywin32. I'm creating them through COM, so I don't tknow if the ActiveX goes through Py_NewInterpreter or not.
>
> Active Scripting creates Python as an out-of-process COM server.

The Active Scripting implementation should register so that inproc or 
out of proc instances can be created (which is the default for all 
pywin32 implemented COM objects).  By default, most things which consume 
script engines (eg, IE, IIS) create inproc engines.

Hence, a single OS process which creates multiple script engines is 
sharing the same Python interpreter between instances. 
Py_NewInterpreter is not used by pywin32's COM support.  This means a 
single OS process using multiple scripting engines will have each engine 
instance sharing the same Python 'environment' (ie, sys.path, loaded 
modules, etc).  If you have control over the host and really want the 
isolated behaviour, you could try explicitly requesting an out of proc 
engine when calling CoCreateInstance.

HTH,

Mark


More information about the python-win32 mailing list