Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#64 Problems with more than one ISAPI extension.

open
nobody
None
5
2007-10-18
2007-10-18
Patrik Simons
No

If you use more than one ISAPI extension at the same
time, then you most probably want one python process per
extension to avoid sharing module level global data. The
default puts all extensions in the same python process.
In Windows 2000 Server Service Pack 4 this can be done
by setting AppProtection=_APP_OUTPROC in the
VirtualDirParameters. (In Service Pack 2 _only_
AppProtection=_APP_INPROC works for me.)

In Windows 2003 Server the AppProtection does nothing as
they use AppPools instead. There you want one AppPool
per extension to get one python process per extension.
I've used the set_app_pool and remove_pool functions
below as the PostInstall and PostRemove arguments to my
VirtualDirParameters to achieve this.

It would be nice if you could add these or similar
helper functions to isapi.install.

from isapi.install import GetObject, _IIS_OBJECT
import pywintypes

def create_pool(pool_name):
try:
pools = GetObject(_IIS_OBJECT+'/AppPools')
except pywintypes.com_error:
return # There are no pools
try:
GetObject(_IIS_OBJECT+'/AppPools/'+pool_name)
except pywintypes.com_error:
# The pool does not exist
pool = pools.Create('IIsApplicationPool', pool_name)
pool.SetInfo()
return pool_name

def delete_pool(pool_name):
try:
pools = GetObject(_IIS_OBJECT+'/AppPools')
pools.Delete('IIsApplicationPool', pool_name)
except pywintypes.com_error:
pass # The pool didn't exist

def set_app_pool(params, options, webdir=None):
if webdir:
if create_pool(pool_name):
webdir.AppPoolID = pool_name
webdir.SetInfo()

def remove_pool(params, options):
delete_pool(pool_name)

Discussion