browser hang

--Apple-Mail=_8E03F269-F806-4DA6-88FB-511BFAB2A7D2
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=utf-8

This is not exactly a perl question, but perl may be implicated. The =
code below writes files to my server, one for each element of @ =
course_file_list. The files are small and the processing is simple and =
should go quickly. It works if the array has only a couple of elements; =
but with a longer list my browser times out saying the server is not =
responding. When I look on the server, all expected files are present. =
The die line near the end was to test whether the loop finished, but I =
never saw a die statement (Fatals to Browser). It=E2=80=99s possible =
that the server timed out before the die statement was reached, but I =
don=E2=80=99t know if I can make the brewers wait longer; and even if I =
could, the processing should not take this long. Being a newbie, I have =
quickly run out of ideas to check. Any suggestions would be appreciated! =
=E2=80=94 Rick Triplett



.. . . SNIP (first hundred lines not shown)
foreach my $course_file (@course_file_list){

    # maybe this course has already been registered
    if ( already_exists($course_file) ){
        $reg_exists .=3D display($course_file);
        next;   # Skip to next $course_file if any
    }

    # try to add 3 data to this progress file and count them to be sure
    my $assignments =3D   # counts the number of assignments - better be =
3!
       ( $pf{n_max},=20
         $pf{course_name},=20
         $pf{effort_report_list}
       ) =3D course_found($course_file); # assign found data to %pf

    # flag and skip if not all assignments are available (likely never)
    if ( $assignments !=3D 3 ){
        $reg_unknown  .=3D display($course_file);
        next;   # Skip to next $course_file if any
    }

    # things are looking good, so write progress file
    if ( write_progress_file($course_file) ){    # successful write
        $reg_yes .=3D display($course_file);=20
        next;   # Skip to next $course_file if any
    }
    else {                                       # unsuccessful write
        $reg_no .=3D display($course_file);
        next;   # Skip to next $course_file if any
    }

}
die "got to line 85";
# serve registration status to browser
report_registrations( $reg_exists,
                      $reg_unknown,=20
                      $reg_yes,=20
                      $reg_no,=20
                    );

exit;


--Apple-Mail=_8E03F269-F806-4DA6-88FB-511BFAB2A7D2
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=utf-8

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dutf-8"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D""><font=
 face=3D"Menlo" class=3D"">This is not exactly a perl question, but perl =
may be implicated. The code below writes files to my server, one for =
each element of @</font>&nbsp;<font face=3D"Menlo" =
class=3D"">course_file_list. The files are small and the processing is =
simple and should go quickly. It works if the array has only a couple of =
elements; but with a longer list my browser times out saying the server =
is not responding. When I look on the server, all expected files are =
present. The die line near the end was to test whether the loop =
finished, but I never saw a die statement (Fatals to Browser). It=E2=80=99=
s possible that the server timed out before the die statement was =
reached, but I don=E2=80=99t know if I can make the&nbsp;brewers wait =
longer; and even if I could, the processing should not take this long. =
Being a newbie, I have quickly run out of ideas to check. =
Any&nbsp;suggestions would be appreciated!&nbsp;=E2=80=94 Rick =
Triplett</font><div class=3D""><font face=3D"Menlo" class=3D""><br =
class=3D""></font></div><div class=3D""><font face=3D"Menlo" =
class=3D""><br class=3D""></font></div><div class=3D""><font =
face=3D"Menlo" class=3D""><br class=3D""></font><div class=3D""><font =
face=3D"Menlo" class=3D"">. . . SNIP (first hundred lines not =
shown)</font></div><div class=3D""><div class=3D""><font face=3D"Menlo" =
class=3D"">foreach my $course_file (@course_file_list){</font></div><div =
class=3D""><font face=3D"Menlo" class=3D""><br =
class=3D""></font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; # maybe this course has already been =
registered</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; if ( already_exists($course_file) =
){</font></div><div class=3D""><font face=3D"Menlo" class=3D"">&nbsp; =
&nbsp; &nbsp; &nbsp; $reg_exists .=3D =
display($course_file);</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; next; &nbsp; # Skip to next =
$course_file if any</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; }</font></div><div class=3D""><font =
face=3D"Menlo" class=3D""><br class=3D""></font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">&nbsp; &nbsp; # try to add 3 =
data to this progress file and count them to be sure</font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">&nbsp; &nbsp; my $assignments =
=3D &nbsp; # counts the number of assignments - better be =
3!</font></div><div class=3D""><font face=3D"Menlo" class=3D"">&nbsp; =
&nbsp; &nbsp; &nbsp;( $pf{n_max},&nbsp;</font></div><div class=3D""><font =
face=3D"Menlo" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;$pf{course_name},&nbsp;</font></div><div class=3D""><font =
face=3D"Menlo" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp;$pf{effort_report_list}</font></div><div class=3D""><font =
face=3D"Menlo" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp;) =3D =
course_found($course_file); # assign found data to %pf</font></div><div =
class=3D""><font face=3D"Menlo" class=3D""><br =
class=3D""></font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; # flag and skip if not all assignments are =
available (likely never)</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; if ( $assignments !=3D 3 ){</font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
$reg_unknown &nbsp;.=3D display($course_file);</font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
next; &nbsp; # Skip to next $course_file if any</font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">&nbsp; &nbsp; =
}</font></div><div class=3D""><font face=3D"Menlo" class=3D""><br =
class=3D""></font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; # things are looking good, so write progress =
file</font></div><div class=3D""><font face=3D"Menlo" class=3D"">&nbsp; =
&nbsp; if ( write_progress_file($course_file) ){ &nbsp; &nbsp;# =
successful write</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; $reg_yes .=3D =
display($course_file);&nbsp;</font></div><div class=3D""><font =
face=3D"Menlo" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; next; &nbsp; # =
Skip to next $course_file if any</font></div><div class=3D""><font =
face=3D"Menlo" class=3D"">&nbsp; &nbsp; }</font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">&nbsp; &nbsp; else { &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; # unsuccessful =
write</font></div><div class=3D""><font face=3D"Menlo" class=3D"">&nbsp; =
&nbsp; &nbsp; &nbsp; $reg_no .=3D =
display($course_file);</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; next; &nbsp; # Skip to next =
$course_file if any</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; }</font></div><div class=3D""><font =
face=3D"Menlo" class=3D""><br class=3D""></font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">}</font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">die "got to line =
85";</font></div><div class=3D""><font face=3D"Menlo" class=3D""># serve =
registration status to browser</font></div><div class=3D""><font =
face=3D"Menlo" class=3D"">report_registrations( =
$reg_exists,</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; $reg_unknown,&nbsp;</font></div><div class=3D""><font=
 face=3D"Menlo" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $reg_yes,&nbsp;</font></div><div =
class=3D""><font face=3D"Menlo" class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
$reg_no,&nbsp;</font></div><div class=3D""><font face=3D"Menlo" =
class=3D"">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; =
&nbsp; &nbsp; );</font></div><div class=3D""><font face=3D"Menlo" =
class=3D""><br class=3D""></font></div><div class=3D""><font =
face=3D"Menlo" class=3D"">exit;</font></div></div><div class=3D""><br =
class=3D""></div></div></body></html>=

--Apple-Mail=_8E03F269-F806-4DA6-88FB-511BFAB2A7D2--
0
perl
10/31/2018 8:11:18 PM
perl.beginners 29317 articles. 3 followers. Follow

1 Replies
10 Views

Similar Articles

[PageSpeed] 35

--00000000000058991405798dd7e1
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Rick,

The first thing I'd do is try to run this snippet from the command-line and
see how long it takes.

On a Linux box, something like:

$ time ./test.pl

Andrew

On Wed, Oct 31, 2018 at 8:11 PM Rick T <perl@reason.net> wrote:

> This is not exactly a perl question, but perl may be implicated. The code
> below writes files to my server, one for each element of @ course_file_li=
st.
> The files are small and the processing is simple and should go quickly. I=
t
> works if the array has only a couple of elements; but with a longer list =
my
> browser times out saying the server is not responding. When I look on the
> server, all expected files are present. The die line near the end was to
> test whether the loop finished, but I never saw a die statement (Fatals t=
o
> Browser). It=E2=80=99s possible that the server timed out before the die =
statement
> was reached, but I don=E2=80=99t know if I can make the brewers wait long=
er; and
> even if I could, the processing should not take this long. Being a newbie=
,
> I have quickly run out of ideas to check. Any suggestions would be
> appreciated! =E2=80=94 Rick Triplett
>
>
>
> . . . SNIP (first hundred lines not shown)
> foreach my $course_file (@course_file_list){
>
>     # maybe this course has already been registered
>     if ( already_exists($course_file) ){
>         $reg_exists .=3D display($course_file);
>         next;   # Skip to next $course_file if any
>     }
>
>     # try to add 3 data to this progress file and count them to be sure
>     my $assignments =3D   # counts the number of assignments - better be =
3!
>        ( $pf{n_max},
>          $pf{course_name},
>          $pf{effort_report_list}
>        ) =3D course_found($course_file); # assign found data to %pf
>
>     # flag and skip if not all assignments are available (likely never)
>     if ( $assignments !=3D 3 ){
>         $reg_unknown  .=3D display($course_file);
>         next;   # Skip to next $course_file if any
>     }
>
>     # things are looking good, so write progress file
>     if ( write_progress_file($course_file) ){    # successful write
>         $reg_yes .=3D display($course_file);
>         next;   # Skip to next $course_file if any
>     }
>     else {                                       # unsuccessful write
>         $reg_no .=3D display($course_file);
>         next;   # Skip to next $course_file if any
>     }
>
> }
> die "got to line 85";
> # serve registration status to browser
> report_registrations( $reg_exists,
>                       $reg_unknown,
>                       $reg_yes,
>                       $reg_no,
>                     );
>
> exit;
>
>

--=20
Andrew Solomon

Perl Trainer, Geekuni http://geekuni.com/
andrew@geekuni.com // +44 7931 946 062

--00000000000058991405798dd7e1
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><img alt=3D"" src=3D"https://app.mailtag.io/email-event/76=
2cdd06-dd5c-11e8-9610-062582205cc4.png?ts=3D2061657272" style=3D"display: n=
one;">Hi Rick,<div><br></div><div>The first thing I&#39;d do is try to run =
this snippet from the command-line and see how long it takes.</div><div><br=
></div><div>On a Linux box, something like:</div><div><br></div><div>$ time=
 ./<a href=3D"http://test.pl">test.pl</a></div><div><br></div><div>Andrew</=
div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr">On Wed, Oct 31, 2=
018 at 8:11 PM Rick T &lt;<a href=3D"mailto:perl@reason.net">perl@reason.ne=
t</a>&gt; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin=
:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style=3D"word=
-wrap:break-word;line-break:after-white-space"><font face=3D"Menlo">This is=
 not exactly a perl question, but perl may be implicated. The code below wr=
ites files to my server, one for each element of @</font>=C2=A0<font face=
=3D"Menlo">course_file_list. The files are small and the processing is simp=
le and should go quickly. It works if the array has only a couple of elemen=
ts; but with a longer list my browser times out saying the server is not re=
sponding. When I look on the server, all expected files are present. The di=
e line near the end was to test whether the loop finished, but I never saw =
a die statement (Fatals to Browser). It=E2=80=99s possible that the server =
timed out before the die statement was reached, but I don=E2=80=99t know if=
 I can make the=C2=A0brewers wait longer; and even if I could, the processi=
ng should not take this long. Being a newbie, I have quickly run out of ide=
as to check. Any=C2=A0suggestions would be appreciated!=C2=A0=E2=80=94 Rick=
 Triplett</font><div><font face=3D"Menlo"><br></font></div><div><font face=
=3D"Menlo"><br></font></div><div><font face=3D"Menlo"><br></font><div><font=
 face=3D"Menlo">. . . SNIP (first hundred lines not shown)</font></div><div=
><div><font face=3D"Menlo">foreach my $course_file (@course_file_list){</fo=
nt></div><div><font face=3D"Menlo"><br></font></div><div><font face=3D"Menl=
o">=C2=A0 =C2=A0 # maybe this course has already been registered</font></di=
v><div><font face=3D"Menlo">=C2=A0 =C2=A0 if ( already_exists($course_file)=
 ){</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0 $reg_=
exists .=3D display($course_file);</font></div><div><font face=3D"Menlo">=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 next; =C2=A0 # Skip to next $course_file if any=
</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 }</font></div><div><fo=
nt face=3D"Menlo"><br></font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 =
# try to add 3 data to this progress file and count them to be sure</font><=
/div><div><font face=3D"Menlo">=C2=A0 =C2=A0 my $assignments =3D =C2=A0 # c=
ounts the number of assignments - better be 3!</font></div><div><font face=
=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0( $pf{n_max},=C2=A0</font></div><div>=
<font face=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0$pf{course_name},=C2=
=A0</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0$pf{effort_report_list}</font></div><div><font face=3D"Menlo">=C2=A0 =C2=
=A0 =C2=A0 =C2=A0) =3D course_found($course_file); # assign found data to %=
pf</font></div><div><font face=3D"Menlo"><br></font></div><div><font face=
=3D"Menlo">=C2=A0 =C2=A0 # flag and skip if not all assignments are availab=
le (likely never)</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 if ( =
$assignments !=3D 3 ){</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 $reg_unknown =C2=A0.=3D display($course_file);</font></div><d=
iv><font face=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0 next; =C2=A0 # Skip to =
next $course_file if any</font></div><div><font face=3D"Menlo">=C2=A0 =C2=
=A0 }</font></div><div><font face=3D"Menlo"><br></font></div><div><font fac=
e=3D"Menlo">=C2=A0 =C2=A0 # things are looking good, so write progress file=
</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 if ( write_progress_fi=
le($course_file) ){ =C2=A0 =C2=A0# successful write</font></div><div><font =
face=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0 $reg_yes .=3D display($course_fi=
le);=C2=A0</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 next; =C2=A0 # Skip to next $course_file if any</font></div><div><font =
face=3D"Menlo">=C2=A0 =C2=A0 }</font></div><div><font face=3D"Menlo">=C2=A0=
 =C2=A0 else { =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #=
 unsuccessful write</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 $reg_no .=3D display($course_file);</font></div><div><font face=
=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0 next; =C2=A0 # Skip to next $course_=
file if any</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 }</font></d=
iv><div><font face=3D"Menlo"><br></font></div><div><font face=3D"Menlo">}</=
font></div><div><font face=3D"Menlo">die &quot;got to line 85&quot;;</font>=
</div><div><font face=3D"Menlo"># serve registration status to browser</fon=
t></div><div><font face=3D"Menlo">report_registrations( $reg_exists,</font>=
</div><div><font face=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 $reg_unknown,=C2=A0</font></div><div><fo=
nt face=3D"Menlo">=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 $reg_yes,=C2=A0</font></div><div><font face=3D"Menlo">=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 $reg_no,=C2=A0</font></div><div><font face=3D"Menlo">=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 );</font></div><div><f=
ont face=3D"Menlo"><br></font></div><div><font face=3D"Menlo">exit;</font><=
/div></div><div><br></div></div></div></blockquote></div><br clear=3D"all">=
<div><br></div>-- <br><div dir=3D"ltr" class=3D"gmail_signature" data-smart=
mail=3D"gmail_signature"><div dir=3D"ltr"><div><div dir=3D"ltr"><div><div d=
ir=3D"ltr">Andrew Solomon<div><span style=3D"font-size:12.8px"><br></span><=
/div><div><span style=3D"font-size:12.8px">Perl Trainer, Geekuni=C2=A0</spa=
n><a href=3D"http://geekuni.com/" style=3D"font-size:12.8px" target=3D"_bla=
nk">http://geekuni.com/</a><br></div><div><a href=3D"mailto:andrew@geekuni.=
com" target=3D"_blank">andrew@geekuni.com</a> // +44 7931 946 062</div></di=
v></div></div></div></div></div>

--00000000000058991405798dd7e1--
0
andrew
10/31/2018 10:29:42 PM
Reply: