On 25/10/2012 13:40, Gilles wrote: > On Thu, 25 Oct 2012 13:03:14 +0100, Tim Golden <m...@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 -- http://mail.python.org/mailman/listinfo/python-list