Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

push_handler and status page question.

by one4k4 (Hermit)
on Mar 31, 2001 at 00:40 UTC ( #68498=perlquestion: print w/ replies, xml ) Need Help??
one4k4 has asked for the wisdom of the Perl Monks concerning the following question:

Morning folks,
I'm currently using mod_perl, and thinking that chaining content headers is the way to go with this, but here is my dillema. (Besides my spelling errors..)

I need to run some stored procedures that take upwards of a minute to generate result sets. Ok, thats grand but I dont want the browser to sit there and twiddle.

I'd like to display an animated gif. Simple. Right? I hope.

I'm looking into stacked handlers in my mod_perl code, but I'm not sure if this is what I need. Is it something in Content-Disposition?

1) Push 'Waiting...' animated gif
2) Process report, Perl waits for result set
3) Perl pushes the report html to the browser as if it opened in a target = _blank window. IE: That same window...
Stumped (or rather -> RTFMing),

_14k4 - webmaster@860.org (www.poorheart.com)

Comment on push_handler and status page question.
Download Code
Re: push_handler and status page question.
by sutch (Curate) on Mar 31, 2001 at 01:06 UTC
    One way to handle this is to use an HTML redirect. This has the added benefit of freeing memory in use by mod_perl processes that would otherwise be used for each waiting client connection.

    An outline of how I've planned to handle it (note: I haven't implemented it yet, but plan to soon):

    receive request; if (request has no job_id) { create new job_id; start processing external commands (providing job_id); return an HTTP redirect with a 10 second pause, such as: <meta http-equiv="REFRESH" content="10;URL=http://sample.com/?id=j +ob_id"> } else { if (external commands have completed) { return results; } else { return the HTTP redirect again; } }
      See, I never really know when the stored procedure will end and return the result set. So I'd really like the 'waiting...' web page to just sit there and refresh with the result set when the SP is done. (As if the connection from $r->send_http_header(...) was kept open... ) This could be anywhere from 3 seconds to 3 minutes. So a content - redirect would probably, most likely, happily, not work. But alas, it is a good idea though.

      _14k4 - webmaster@860.org (www.poorheart.com)
        I know that one of the major browsers, and maybe just one version of that browser, will redraw the page when new headers are returned. But if you cannot guarantee that your users will use that browser, either IE or NS, then this solution is not viable.

        You may be able to do something with JavaScript, where your image is returned and then hidden when the results are returned.

        I do not understand why you believe the HTTP redirect will not work. If you are concerned about the user having to wait an extra 9 seconds (when using a 10 second delay) then decrease the delay to 5 seconds or even 1 second.

Re: push_handler and status page question.
by one4k4 (Hermit) on Apr 10, 2001 at 19:17 UTC
    I think this is how I'm going to solve this issue. Once I get some time to get back to it again.

    Setup a table in a DB.
    Fork off the process like I was originally going to.
    The result set is stored in the DB. Or, a ref to it. Or something similar.
    The script is sent an ID. Which is the KEY value to the DB the result sets are stored in.
    First thing the script does is check for data in the result_set column, based apon the sent key.

    Yes data, then the result set must be done. So spit_out_html();
    No data, then the result set must not be done. Refresh and try again.
    No Key. When it was never created. Go fork and create the key and refresh to wait for a result set.
    Sound like a plan? We'll see what happens. I'll keep everybody updated on my solution.
    Thank you for all the advice as well. Its been a big help.


    _14k4 - webmaster@poorheart.com (www.poorheart.com)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://68498]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (11)
As of 2014-07-22 18:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (126 votes), past polls