[cgiapp] Streaming Status Updates for a Long-running Run Mode
Michael Peters
mpeters at plusthree.com
Wed Oct 7 11:44:22 EDT 2009
On 10/07/2009 11:35 AM, eric.berg at barclayscapital.com wrote:
> The approach I'm working on now is to have a global status hash for each
> file being processed, which I'll update as I run each subprocess and
> when each completes. Then I've thrown in a quick run mode that simply
> sends that hash back as JSON and I'm putting some logic into my page to
> periodically make a request for this runmode so I can update the page
> with current status info.
I really wouldn't do that. Don't tied up your web server for long
running tasks just so that you can wait to show a status to the user.
Even something as simple as Unix "at" for a simple queue would be better.
> On a related note, is there a way to have cgiapp send content back to
> the client during the processing of a run mode instead of at the end
> when the rm returns?
No, not for Ajax. And it's not a limitation of cgiapp, but of HTTP/Ajax.
For non-Ajax you use Non-Parsed-Headers (NPH) which means you tell C::A
to not send headers and you then instead print them yourselves. And then
periodically print more things to the client (like some JS that updates
a progress bar, etc). But like I said in the other email, this won't
work for Ajax.
--
Michael Peters
Plus Three, LP
More information about the cgiapp
mailing list