Question about long-running web scripts

Tim Golden mail at timgolden.me.uk
Thu Oct 25 09:24:16 EDT 2012


On 25/10/2012 13:40, Gilles wrote:
> On Thu, 25 Oct 2012 13:03:14 +0100, Tim Golden <mail at timgolden.me.uk>
> wrote:
>> (Your question is a little confused at the end. I'm choosing to
>> understand: why can't we just run Python one-shot, like CGI? The likely
>> alternative meaning is: why can't the incoming request be routed to an
>> already-running Python program -- which is not, of course, what CGI
>> generally does. Hence my confusion).
> 
> Yes indeed. Sorry about the confusion.
> 
> But actually, I didn't mean one-shot scripts, where the Python
> interpreter + script must be loaded each time, but rather: If I leave
> a Python running in an endless loop, why not just use either CGI or
> some other basic way to call the script instead of FastCGI?

In essence, you're describing FastCGI. A Python program (or, indeed, any
program) which uses FastCGI runs continuously and waits for the incoming
request on a TCP socket (instead of as a sys.stdin stream + env vars
immediately after process startup).

The key description is here:

  http://www.fastcgi.com/drupal/node/6?q=node/15

(The sections have no anchors; you're looking for the section titled "2.
FastCGI Interface")

TJG



More information about the Python-list mailing list