Ian Bicking: the old part of his blog

Python FastCGI Server?

Dear LazyWeb,

Is there a Python module that implements the server side of the FastCGI protocol? I.e., when Apache connects to some process, it is implementing the server side, and the process is implementing the client side.

Created 12 Jul '06


This doesn't answer your question, but there's a twisted module that acts as a FastCGI client and is documented well enough to be able to write a server with it. Code here.

It's buggy, mind (and probably hasn't been tested) - my previous attempt to use it failed on account of line 129 should mention valueLen twice. I gave up an wrote my own redirect in mod_python. To make up for this, it does have a good rant about FastCGI at the top...

Ian, You need to explain more - why do you have a need for interfacing with an existing FastCGI server?

# Jeremy

That would be really useful for being able to use Python as middleware for interfacing with PHP code.

Good luck!

# Peter Russell

Yes, that's the sort of thing I want to use it for.

# Ian Bicking

flup maybe? http://www.saddi.com/software/flup/

Haven't used it, but I've seen it suggested in a number of places for FastCGI support...

Django: http://www.djangoproject.com/documentation/fastcgi/

TurboGears: http://www.turbogears.org/docs/deployment/lighttpd.html

web.py: http://webpy.org/

# Brendan O'Connor

These are all the client side, though I'll probably be using that for reference if nothing comes up. I believe all of these are using Flup, though there is also a fcgi module in jonpy that is also used some places (might have been used for Flup for all I know).

# Ian Bicking

Swap 'client' and 'server' terms, please. When apache connects to FastCGI application, application is the server, and apache is the client, because apache/mod_fastcgi sends _request_ and application _serves_ it. Client requests, server replies. Browser is the client for web-server, but web-server is the client for application(s) server(s).

# checat

Yes, "server" is not really a good description. It's the server side of the equation, but the server is a client of the FastCGI protocol, in that the server requests and the FastCGI app responds. This is the same problem with X terminology.

Really we should have words that mean closer to human/user and further from human/user, because this is often what we are really concerned about, or can most easily understand when considering the architecture. Note that developers don't count as humans in this equation ;)

# Ian Bicking