What roboticus said. CGI applications, as I'm sure you must know, work by writing their output to stdout. If your application spends a long time thinking without generating any traffic on stdout something is bound to give up with the result that at the browser end nothing seems to happen.

Also as roboticus said, if you don't show us some code we can't help a lot. Pare down your code to just the problematic loop. If you need data, fake it. If the database takes a long time in the real code put a delay in the sample where the database code would be called. You should be able to reproduce a sketch of the code in a few dozen runable lines of code.

Most likely you can restructure your code to remove most of the database overhead, but we can't tell without seeing at least a sketch.

Premature optimization is the root of all job security

In reply to Re: CGI hangs unless print by GrandFather
in thread CGI hangs unless print by janedoh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.