You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by tl...@860.org on 2001/04/02 16:06:40 UTC

Long waits on SQL Stored Procs. Should I use chained content handlers?

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 chained handlers in my mod_perl code, but I'm not sure if this 
is what I need. 

0) Request page and report.
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), 

Any ideas?  I cant, for the life of me, figure out how this would work with 
http redirects, and thought there might be something with mod_perl that would 
help this.  Fork() maybe.  I'm trying a few ideas.

Thanks a bunch.  If this is slightly OT, I apologize.

Tom Sullivan,
webmaster@860.org

---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/



Re: Long waits on SQL Stored Procs. Should I use chained contenthandlers?

Posted by Robert Landrum <rl...@capitoladvantage.com>.
At 7:49 AM -0700 4/3/01, Wim Kerkhoff wrote:
>Robert Landrum wrote:
>>
>> At 2:06 PM +0000 4/2/01, tls@860.org wrote:
>
>> >Any ideas?  I cant, for the life of me, figure out how this would work with
>> >http redirects, and thought there might be something with 
>>mod_perl that would
>> >help this.  Fork() maybe.  I'm trying a few ideas.
>>
>> It's probably out of date, but the CGI::Push module does exactly 
>>what you want.
>>
>> The doc isn't real clear, but I've used this once to do exactly what
>> you're doing.  Unfortunatly, I can no longer find the code I wrote...
>>
>> Basically, CGI::Push sends a multipart mime message to the browser.
>> The first part of that is an HTML document, which the browser renders
>> immediatly.  The second part is the confirmation HTML, which the
>> browser also renders in place of the original document.
>
>Does this work with non-Netscape browsers, such as IE? I was going to
>suggest this multipart MIME trick, but I thought I read in the CGI.pm
>book that server push only worked with Netscape browsers.

Actually, It doesn't work at all anymore.  I just tested it with 
Netscape and IE.  Bummer.  I wrote the code back in 1998 or 1999... I 
guess that would have been Netscape 3.0 and IE 4.  Browser technology 
peaked with lynx.  At least you can expect the same results with just 
about every version ever written.

Rob

--
As soon as you make something foolproof, someone will create a better fool.

Re: Long waits on SQL Stored Procs. Should I use chained contenthandlers?

Posted by Wim Kerkhoff <wi...@merilus.com>.
Robert Landrum wrote:
> 
> At 2:06 PM +0000 4/2/01, tls@860.org wrote:

> >Any ideas?  I cant, for the life of me, figure out how this would work with
> >http redirects, and thought there might be something with mod_perl that would
> >help this.  Fork() maybe.  I'm trying a few ideas.
> 
> It's probably out of date, but the CGI::Push module does exactly what you want.
> 
> The doc isn't real clear, but I've used this once to do exactly what
> you're doing.  Unfortunatly, I can no longer find the code I wrote...
> 
> Basically, CGI::Push sends a multipart mime message to the browser.
> The first part of that is an HTML document, which the browser renders
> immediatly.  The second part is the confirmation HTML, which the
> browser also renders in place of the original document.

Does this work with non-Netscape browsers, such as IE? I was going to
suggest this multipart MIME trick, but I thought I read in the CGI.pm
book that server push only worked with Netscape browsers.

-- 

Regards,

Wim Kerkhoff

Re: Long waits on SQL Stored Procs. Should I use chained content handlers?

Posted by Robert Landrum <rl...@capitoladvantage.com>.
At 2:06 PM +0000 4/2/01, tls@860.org wrote:
>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 chained handlers in my mod_perl code, but I'm not 
>sure if this
>is what I need.
>
>0) Request page and report.
>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),
>
>Any ideas?  I cant, for the life of me, figure out how this would work with
>http redirects, and thought there might be something with mod_perl that would
>help this.  Fork() maybe.  I'm trying a few ideas.




It's probably out of date, but the CGI::Push module does exactly what you want.

The doc isn't real clear, but I've used this once to do exactly what 
you're doing.  Unfortunatly, I can no longer find the code I wrote...

Basically, CGI::Push sends a multipart mime message to the browser. 
The first part of that is an HTML document, which the browser renders 
immediatly.  The second part is the confirmation HTML, which the 
browser also renders in place of the original document.

The basic syntax is

use CGI::Push qw/:standard/;

do_push(-next_page => \&header);
sleep 30;
do_push(-next_page => \&body);
do_page(-next_page => sub { return undef; });

&header and &body both return a FULL html document, including the 
headers.  Returning undef terminates the connection with the browser.

Good luck,

Rob

--
As soon as you make something foolproof, someone will create a better fool.

Re: Long waits on SQL Stored Procs. Should I use chained content handlers?

Posted by "Ken Y. Clark" <kc...@logsoft.com>.
On Mon, 2 Apr 2001 tls@860.org wrote:

> Date: Mon, 2 Apr 2001 14:06:40 GMT
> From: tls@860.org
> To: modperl@apache.org
> Subject: Long waits on SQL Stored Procs.  Should I use chained content
    handlers?
> 
> 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 chained handlers in my mod_perl code, but I'm not sure if this 
> is what I need. 
> 
> 0) Request page and report.
> 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), 
> 
> Any ideas?  I cant, for the life of me, figure out how this would work with 
> http redirects, and thought there might be something with mod_perl that would 
> help this.  Fork() maybe.  I'm trying a few ideas.
> 
> Thanks a bunch.  If this is slightly OT, I apologize.
> 
> Tom Sullivan,
> webmaster@860.org
> 
> ---------------------------------------------
> This message was sent using Endymion MailMan.
> http://www.endymion.com/products/mailman/
> 
> 

Could you make the page displaying the animated gif have a "refresh" tag
of maybe 30 (or fewer) seconds, at the end of which it could redirect
to a page that could see if the query has finished?  If not, it would
return to the animated gif page again and wait some more.

ky


RE: Long waits on SQL Stored Procs. Should I use chained content handlers?

Posted by David Harris <dh...@drh.net>.
One could handle this all in one request with an HTML layer controlled by
JavaScript that performs counting for the user. This is better that multiple
requests because you don't have to try starting processing in one HTTP
request and giving the result to another HTTP request. Run everything in one
request and life is simpler.

For an example of something I have working go to
http://www.drh.net/site/domain/new.shtml
and then search for a domain.

The box that pops up before the page has fully loaded is a layer. View the
source to see the JavaScript code controlling the layer. Replace my
machinery to perform a count in the layer with a simple animated gif if you
like.

I don't have any public examples that show how it works when the page takes
a while to load. Those are all on the internal website.

Here is the code:
http://www.davideous.com/misc/Fusion-Countdown.pm

This code not supported. This is the basic idea: take it and run.

David Harris
President, DRH Internet Inc.
dharris@drh.net
http://www.drh.net/

-----Original Message-----
From: tls@860.org [mailto:tls@860.org]
Sent: Monday, April 02, 2001 10:07 AM
To: modperl@apache.org
Subject: Long waits on SQL Stored Procs. Should I use chained content
handlers?

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 chained handlers in my mod_perl code, but I'm not sure if
this
is what I need.

0) Request page and report.
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),

Any ideas?  I cant, for the life of me, figure out how this would work with
http redirects, and thought there might be something with mod_perl that
would
help this.  Fork() maybe.  I'm trying a few ideas.

Thanks a bunch.  If this is slightly OT, I apologize.

Tom Sullivan,
webmaster@860.org

---------------------------------------------
This message was sent using Endymion MailMan.
http://www.endymion.com/products/mailman/


Re: returning HTTP error code

Posted by Helios de Creisquer <cr...@zehc.net>.
"Jeffrey W. Baker" wrote:
> sub handler {
>     my $r = shift;
>     $r->status(503);
>     $r->send_http_header;
> 
>     return OK; #or return SERVER_ERROR; depends on how want to do it.
> }

Wow, pretty simple, in fact, thx a lot ! :-)

Cheers.
-- 
Helios     de     Creisquer
mail:     helios@balios.org

Re: returning HTTP error code

Posted by "Jeffrey W. Baker" <jw...@acm.org>.

On Thu, 5 Apr 2001, Helios de Creisquer wrote:

> Hi !
>
> I've got a mod_perl script calling an external program which
> use much memory. And I would like to send a 503 instead of
> calling this external program when there is less than xxxMB
> of memory free.
>
> Is mod_perl provides this ability to decide to send
> an HTTP return code or another ?

sub handler {
    my $r = shift;
    $r->status(503);
    $r->send_http_header;

    return OK; #or return SERVER_ERROR; depends on how want to do it.
}

-jwb


returning HTTP error code

Posted by Helios de Creisquer <cr...@zehc.net>.
Hi !

I've got a mod_perl script calling an external program which
use much memory. And I would like to send a 503 instead of
calling this external program when there is less than xxxMB
of memory free.

Is mod_perl provides this ability to decide to send 
an HTTP return code or another ?

Thx for your answers...

Cheers.
-- 
Helios     de     Creisquer
mail:     helios@balios.org

Re: Long waits on SQL Stored Procs. Should I use chained content handlers?

Posted by Cees Hek <ce...@sitesuite.net>.
Since Apache can't respond to the request until the File has been uploaded
completely (at least this is what I understand, but I could be wrong), you
won't be able to do anything on the server side to handle this.

You could use what has been suggested by someone else (sorry, but I don't
remember who), and that is to have an onSubmit on the form that triggers
some JavaScript that pops up a layer overtop of the current page.  I don't
know enough about layers, but you might even be able to load a new page
into the layer while the form is being submitted.  When the upload is
completed, the entire document will be replaced with the response from the
server.

One issue that I see with this is, what happens if the upload fails, and
the connection is dropped...

Cees Hek


On Wed, 4 Apr 2001, Issac Goldstand wrote:

> Out of curiosity, what if the original page contains a form with an upload
> field?  Any suggestions/ideas on how to provide a similar strategy?  The
> problem with the scenario is that it's the upload that will probably take
> the most time...
>
> On Tue, 3 Apr 2001, Cees Hek wrote:
> 
> > On Mon, 2 Apr 2001 tls@860.org wrote:
> > 
> > > 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.
> > 
> > Why can't you just display your animated gif on a page with a refresh tag
> > that loads the real page with the query in it.  A refresh meta tag doesn't
> > have to reload the same page again, you can redirect it to another URL.  
> > Your gif would be displayed, and you query would start right away.  
> > 
> > You have to make sure that you don't send out any data from your query
> > script until you are ready to display the entire thing.  The browser will
> > not clear the screen until it receives some data from the server.
> > 
> > The only other issue here is browser timeouts.  If the page takes too long
> > to display, the browser may drop the connection, but I've found that if a
> > browser makes a connection, it will wait for a 'long' time for data to
> > show up.  I don't have any numbers, but it would be trivial to test.
> > 
> > This method is great to stop people from hitting a link repeatedly if a
> > page doesn't load right away.
> > 
> > I've included a simple HTML page that we use to generate some reports that
> > take up to 30 seconds to display
> > 
> > Cees Hek
> > 
> > 
> > <html>
> > <head>
> > <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> > <META HTTP-EQUIV="REFRESH" CONTENT="0; URL=reports.cgi?sessionid=?????">
> > </head>
> >  
> > <body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0"
> > bgcolor="#FFFFFF">
> >  
> > <table width="100%" height="100%" border="0" cellspacing="0"
> > cellpadding="0" bgcolor="#FFFFFF" align=center>
> >  <tr>
> >   <td align="center" valign="center">
> >    <font face="verdana,arial,helvetica" size=4 color=red>
> >    Please wait while creating reports...</font>
> >   </td>
> >  </tr>
> > </table>
> > </body>
> > </html>
> > 
> 
> 
> 

-- 
Cees Hek
SiteSuite Corporation
cees@sitesuite.net


Re: Long waits on SQL Stored Procs. Should I use chained content handlers?

Posted by Issac Goldstand <is...@mail.jct.ac.il>.
Out of curiosity, what if the original page contains a form with an upload
field?  Any suggestions/ideas on how to provide a similar strategy?  The
problem with the scenario is that it's the upload that will probably take
the most time...

  Issac

Internet is a wonderful mechanism for making a fool of
yourself in front of a very large audience.
  --Anonymous

Moving the mouse won't get you into trouble...  Clicking it might.
  --Anonymous

PGP Key 0xE0FA561B - Fingerprint:
7E18 C018 D623 A57B 7F37 D902 8C84 7675 E0FA 561B


On Tue, 3 Apr 2001, Cees Hek wrote:

> On Mon, 2 Apr 2001 tls@860.org wrote:
> 
> > 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.
> 
> Why can't you just display your animated gif on a page with a refresh tag
> that loads the real page with the query in it.  A refresh meta tag doesn't
> have to reload the same page again, you can redirect it to another URL.  
> Your gif would be displayed, and you query would start right away.  
> 
> You have to make sure that you don't send out any data from your query
> script until you are ready to display the entire thing.  The browser will
> not clear the screen until it receives some data from the server.
> 
> The only other issue here is browser timeouts.  If the page takes too long
> to display, the browser may drop the connection, but I've found that if a
> browser makes a connection, it will wait for a 'long' time for data to
> show up.  I don't have any numbers, but it would be trivial to test.
> 
> This method is great to stop people from hitting a link repeatedly if a
> page doesn't load right away.
> 
> I've included a simple HTML page that we use to generate some reports that
> take up to 30 seconds to display
> 
> Cees Hek
> 
> 
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
> <META HTTP-EQUIV="REFRESH" CONTENT="0; URL=reports.cgi?sessionid=?????">
> </head>
>  
> <body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0"
> bgcolor="#FFFFFF">
>  
> <table width="100%" height="100%" border="0" cellspacing="0"
> cellpadding="0" bgcolor="#FFFFFF" align=center>
>  <tr>
>   <td align="center" valign="center">
>    <font face="verdana,arial,helvetica" size=4 color=red>
>    Please wait while creating reports...</font>
>   </td>
>  </tr>
> </table>
> </body>
> </html>
> 


Re: Long waits on SQL Stored Procs. Should I use chained content handlers?

Posted by Cees Hek <ce...@sitesuite.net>.
On Mon, 2 Apr 2001 tls@860.org wrote:

> 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.

Why can't you just display your animated gif on a page with a refresh tag
that loads the real page with the query in it.  A refresh meta tag doesn't
have to reload the same page again, you can redirect it to another URL.  
Your gif would be displayed, and you query would start right away.  

You have to make sure that you don't send out any data from your query
script until you are ready to display the entire thing.  The browser will
not clear the screen until it receives some data from the server.

The only other issue here is browser timeouts.  If the page takes too long
to display, the browser may drop the connection, but I've found that if a
browser makes a connection, it will wait for a 'long' time for data to
show up.  I don't have any numbers, but it would be trivial to test.

This method is great to stop people from hitting a link repeatedly if a
page doesn't load right away.

I've included a simple HTML page that we use to generate some reports that
take up to 30 seconds to display

Cees Hek


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="REFRESH" CONTENT="0; URL=reports.cgi?sessionid=?????">
</head>
 
<body marginheight="0" marginwidth="0" topmargin="0" leftmargin="0"
bgcolor="#FFFFFF">
 
<table width="100%" height="100%" border="0" cellspacing="0"
cellpadding="0" bgcolor="#FFFFFF" align=center>
 <tr>
  <td align="center" valign="center">
   <font face="verdana,arial,helvetica" size=4 color=red>
   Please wait while creating reports...</font>
  </td>
 </tr>
</table>
</body>
</html>