CGI output

Sebastien Delafond sdelafond at vertical.net
Mon Nov 19 21:18:33 CET 2001


OK, thanks to all for your input. Here's my feedback now :)

> Before coming up with a solution for displaying a progress indicator in some
> fashion (which is a nasty idea, over the web), consider speeding up your
> algorithm, or moving the slow parts to C code. Maybe you're doing something
> wrong, and should never have to even think of doing a "wait screen" of some
> type (if the task can actually be completed in, say, 15 seconds).
> 
> Perhaps if you mentioned what you were doing, and what the slow parts of
> your code are, we could help you with that. If you think theres /no way/ you
> could make it this much faster, ask Guido:
> http://python.org/doc/essays/list2str.html

I understand one should always try to enhance its programs from an
algorithmic approach, in order to make them faster, and eventually get
rid of the unnecessary progress report. And yeah, I've already been
reading on some of Guido's fine code enhancements to run faster...
But unfortunately, the script I call from my python CGI script is a
bash script that pull Java sources from the CVS, then builds and
packages them; I'm sure you'll agree that there's not much I can do to
speed up that Java compilation :>

> This works with my Apache configuration. If it doesn't work as expected, it
> might be a webserver configuration problem. For example, the following CGI
> script is displayed line by line in my browser:
[snip]
>  sys.stdout.flush()
  
of course, this is what I was missing : the ouptut was buffered at the
Python level, so there was no way for me to retrieve it on the web
server side...
There shouldn't be any work involved on the Apache (which I'm using)
side, since one can read from the FAQ :

< As of Apache 1.3, CGI scripts are essentially not buffered. Every
time your
< script does a "flush" to output data, that data gets relayed on to
the
< client. 
[snip]
< Prior to 1.3, you needed to use "nph-" scripts to accomplish
non-buffering.
< Today, the only difference between nph scripts and normal scripts is
that nph
< scripts require the full HTTP headers to be sent

Thanks to all, and especially to Gerhard :)

--Seb



More information about the Python-list mailing list