I have a Pylons controller that is called via jQuery $.ajaxSubmit(). It executes a long-running operation and I want to have it return progress messages before the entire output is available. As a simple proof of concept I've tried this:
response.body_file.write('<script>OnExecutionProgress("Starting");</script>\n')
time.sleep(2)
response.body_file.write('<script>OnExecutionProgress("Finished");</script>\n')
However, this doesn't return the first message to the client immediately - the entire output is returned only at the end.
I've done something like this previously in ASP.NET using Response.Write()
and Response.Flush()
and it worked well. Calling response.body_file.flush()
in Pylons seems to make no difference, though.