python cgi speedup on iis

Robert Brewer fumanchu at amor.org
Wed Aug 25 03:58:56 CEST 2004


Charlie Taylor wrote:
> >> I'm looking for advice on how to speed up python cgi on 
> Windows IIS ...
> 
> Gilles Lenfant wrote:
> >Use the excellent pywin32
> >http://sourceforge.net/projects/pywin32
> >Look at the help in the "ASP and Python" section that shows 
> how to register
> >Python as ASP engine...
> 
> pywin32 ASP turned out to be EXACTLY what I needed.
> 
> It took very little effort to convert my CGI scripts, and the 
> performance
> boost was terrific.
> 
> There are a few nagging issues regarding the reload of 
> modified modules.
> The ASP engine often overlooks changed pyc files and 
> therefore does not
> reload the modified modules (this requires IIS restarts), 
> however, it is
> very good at detecting changes to the ASP files themselves.  
> I've taken to
> debugging imported modules via CGI scripts to get around 
> having to restart
> IIS.

I ended up writing a reload tool for admins to use from the webapp
itself. Lots of hooks here to functions you never heard of, but it
should give you the idea:

def reimport(UI):
    """Reload the requested module.
    
    reload = module name
    """
    
    if not UI.user in UI.application.superusers:
        raise dejavu.AccessDeniedError
    
    redir = html.RedirectPage(UI.application)
    UI.write(redir.top(u'Reloading...'))
    
    # Locate the requested module.
    moduleName = UI.requestParams.get(u'module', u'')
    try:
        reqModule = sys.modules[moduleName]
    except KeyError:
        raise StandardError(u"Module '%s' could not be found." %
moduleName)
    reload(reqModule)
    
    UI.write(redir.bottom(UI.root() + u'/admin.htm'))


HTH,


Robert Brewer
MIS
Amor Ministries
fumanchu at amor.org



More information about the Python-list mailing list