[cgiapp] Streaming Status Updates for a Long-running Run Mode

eric.berg at barclayscapital.com eric.berg at barclayscapital.com
Wed Oct 7 11:35:17 EDT 2009


Thanks, Michael.  Good point about AJAX not returning until the entire
request is done.

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.

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?

Eric

> -----Original Message-----
> From: cgiapp-bounces at lists.openlib.org 
> [mailto:cgiapp-bounces at lists.openlib.org] On Behalf Of Michael Peters
> Sent: Wednesday, October 07, 2009 11:28 AM
> To: CGI Application
> Subject: Re: [cgiapp] Streaming Status Updates for a 
> Long-running Run Mode
> 
> On 10/07/2009 10:33 AM, eric.berg at barclayscapital.com wrote:
> 
> > How can I update my web page with status from this run mode 
> while the
> > subprocesses are running?
> 
> There's a couple of different ways this can be done. The best is 
> definitely not the easiest but it means creating a separate 
> offline job 
> queue that can run these processes and keep their status in a shared 
> location (like a DB, etc). Then your rm just adds a job to 
> the queue and 
> returns. Then when you're checking on the status via Ajax you need to 
> have another rm that simply checks on the status of the job 
> and returns 
> a flag that could mean success, failure, or try again later 
> (still working).
> 
> Unfortunately, since you are using Ajax, you can't use the 
> standard NPH 
> approach and just periodically print something to the browser 
> while it's 
> working. Ajax requests don't return (in the javascript) until 
> the entire 
> request is done and it will probably timeout on you.
> 
> -- 
> Michael Peters
> Plus Three, LP
_______________________________________________

This e-mail may contain information that is confidential, privileged or otherwise protected from disclosure. If you are not an intended recipient of this e-mail, do not duplicate or redistribute it by any means. Please delete it and any attachments and notify the sender that you have received it in error. Unless specifically indicated, this e-mail is not an offer to buy or sell or a solicitation to buy or sell any securities, investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Barclays. Any views or opinions presented are solely those of the author and do not necessarily represent those of Barclays. This e-mail is subject to terms available at the following link: www.barcap.com/emaildisclaimer. By messaging with Barclays you consent to the foregoing.  Barclays Capital is the investment banking division of Barclays Bank PLC, a company registered in England (number 1026167) with its registered office at 1 Churchill Place, London, E14 5HP.  This email may relate to or be sent from other members of the Barclays Group.
_______________________________________________


More information about the cgiapp mailing list