python cgi problem
Gerhard Häring
gerhard at bigfoot.de
Mon Mar 25 07:27:55 EST 2002
In article <1573b893.0203250317.693ef1dc at posting.google.com>, etienne wrote:
> hi there !
>
> I'm programming such a cgi:
> step 1- user submits some data
> step 2- cgi validates data
> step 3- outputs a html file telling the user to wich url point to find
> output
> step 4- do the hard work.
>
> the reason for step 3 is that step 4 needs to dig in a very large
> database, and may take lot of time
>
> everything woks fine but output of step3 comes when step 4 is over and
> user needs to wait up to some minutes for his response.
>
> cgi schema is as follow:
>
> def main():
> # 2
> params = validate_params()
> # 3
> htm_out = generate_output()
> print htm_out
> # 4
> os.system(" python my_module.py params &")
>
>
> I can see results of print htm_out when os.system(" python
> my_module.py params &") is over
>
> can i force htm_out output somehow ???
You want to have unbuffered output? Starting Python with "python -u" probably
is what you want, then:
-u : unbuffered binary stdout and stderr (also PYTHONUNBUFFERED=x)
Gerhard
More information about the Python-list
mailing list