[python-win32] Options for running Python under IIS?

Preston Landers planders at gmail.com
Thu Nov 12 00:03:25 CET 2009


Hello, all!

I'm a Python developer trying to get my web app working smoothly under
IIS on Windows - in particular with FastCGI though I am open to other
options.  I posted on the IIS community forums about Python and
FastCGI but haven't heard a response there:

http://forums.iis.net/p/1162433/1923802.aspx#1923802

The Unix version of my app is based on FastCGI using Flup.  (It
doesn't use Django or any other public framework, just some hand
rolled stuff.)  I've got a FastCGI (TCP) based Python service up and
running on Windows, thanks to a patched socket module with fromfd()
and related patches to Flup that I provide.

IIS 7 has a built-in FastCGI plugin but apparently it doesn't work
with TCP based servers to my great dismay and seems to be only tested
with PHP.  It seems to want to manage the launching of backend
processes itself.  I'd be fine with this if I could tell exactly what
interface the IIS FastCGI plugin expects of its executables.  PHP has
a php-cgi.exe program; has anyone looked at this to see what a Python
equivalent might involve?

By the way I understand that Python 3 already has the fromfd / dup
functionality available.  My patch is basically very similar to one
posted here:  http://bugs.python.org/issue1378

Anyway the purpose of this post is just to see if anyone else is
struggling with this issue.  As I see it these are my options right
now for running Python code under IIS:

1) Plain old CGI - I can get this working but obviously it's not
optimal for performance.

2) "Classic ASP" with Python.  This seems OK I guess except "classic"
ASP is deprecated and/or obsolete by this point.  There might also be
issues with thread safety?  My app has never been run or tested in a
threaded execution environment.  Older versions of my app use Classic
ASP Python to talk to backend app servers over a proprietary socket
protocol.  At least on the Unix side I got rid of this protocol by
switching to FastCGI.  Under this solution I'd either run my code
directly under ASP or else use it as a FastCGI-TCP front end.

3) FastCGI under IIS would be my preferred solution but see above.

4) Use isapi-wsgi:  This seems to be getting more popular but it seems
to use threads and I'm wondering whether this will break my app in
subtle ways.  I make heavy use of various Python C extension modules
which may not be fully threadsafe.  Also within my app code there is
extensive use of unprotected module-level Python variables.  Or am I
misunderstanding how this works?

Are there any other good options that I am missing?  Even if
isapi-wsgi is quite viable (and I plan to start playing with it more
this week) it'd still be awesome if we (Python) could work with the
IIS FastCGI plugin with something like a python-cgi.exe.

thanks,
-Preston Landers - planders at gmail dot com


More information about the python-win32 mailing list