[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] how to do a progress bar or similar?


We've done this in Krang (http://krang.sf.net) without forking a separate
process - it's used to show progress during preview/publish of story and
media objects.  We did it as follows:

At the beginning of the run-mode, we immediately return a no-parse header, 
along with the template that provides the frame for the output.  That 
template also contains the progress bar/thermometer, and the javascript 
necessary to update it.

The runmode then calls the method that does the actual work, and passes in 
a callback subroutine ref as a parameter.  As the method does its work, it 
periodically calls the callback, which outputs a single line, the 
javascript call to update the browser.

The code is part of a pretty extensive module, I'd rather not summarize it 
here and give you possibly broken code.  But you can find it yourself - 
look at preview_story() and publish_story() in Krang::CGI::Publisher
(KRANG_ROOT/lib/Krang/CGI/Publisher).

	--pete




On Tue, 3 Aug 2004, Mark A. Fuller wrote:

> It was discussed in 
> 
> http://www.mail-archive.com/suppressed/msg01851.html
> 
> which has a link to a lengthy article with sample code.  The lengthy article says the forked child would update a session cache and the parent would continuously check the cache to see if the child completed. Wouldn't it be more straightforward for the parent to perform a "waitpid"? When the child exits and the parent receives notice of this event (via waitpid), it could proceed to check the session cache for more detailed information about the final disposition of that process.
> 
> Mark
> 
> 
> -----Original Message-----
> From: Michael Peters <suppressed>
> Sent: Aug 3, 2004 6:47 AM
> To: cgiapp <suppressed>
> Subject: Re: [cgiapp] how to do a progress bar or similar?
> 
> Andreas Schuldei wrote:
> > hi!
> > 
> > how can i implement some kind of progress indicator?
> > 
> > in one part of my app it is hard to tell for the user on the
> > remote webbrowser that something is happening and everything goes
> > according to plan (during account mass-generation).
> > 
> > how can i print out the processed usernames or just dots or some
> > other nice "we are getting there" indicator?
> > 
> > I feel this is a bit against  CGI::Applications basic way of
> > operation, since it usually outputs the *finished* page.
> > 
> > How do i do this cleanly and well integrated into the framework?
> > anyone with some example code?
> 
> Believe it or not, this is a question that is brought up many times 
> here. Since I might not remember all of the good suggestions, you might 
> want to search the archives.
> 
> Briefly, it involves taking the data to be processed, forking off a 
> child to actually do the processing (or having a cron job/daemon doing 
> the processing). Then you return a 'please wait' screen to the user 
> maybe with an animated gif progress bar. This please wait screen will 
> continually refresh. When the work being done in the background is 
> finished, you can have it set some sort of flag/file, etc telling the 
> 'please wait' page that is refreshing that it's done, so the next time 
> it refreshes it shows the user what they want.
> 
> Or you could have the page returned to the user tell them that the 
> results will be emailed to them (sometimes this is more 
> appropriate/necessary if the processing takes several minutes or more).
> 
> HTH
> 
> Michael Peters
> Developer
> Plus Three
> 
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/suppressed/
>               http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
> 
> 
> 
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/suppressed/
>               http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
> To unsubscribe, e-mail: suppressed
> For additional commands, e-mail: suppressed
> 



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.