janedoh:
Without seeing what code you're running, it's hard to come up with a possible answer. You don't need to provide everything, just pare down your application until you can reproduce the issue with a small bit of code. The nice thing about going through the exercise of trimming out unrelated parts of code is that it will frequently lead you to the answer, or at least provide you a couple nice hints.
I don't personally work with CGI, but I'm sure that if it had a hanging problem, someone would've noticed it by now. If I had to guess (and without code, that's all I can do), I'd imagine that your process is taking a while to run, and without I/O occurring (via your print statements), the connection is timing out and disconnecting so you don't see any results.
...roboticus
When your only tool is a hammer, all problems look like your thumb.
| [reply] |
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
| [reply] |
It needs a print statement or it will hang.
In the absence of any code, I will guess that it doesn't actually hang but instead times out. The web server and the web client will both have timeouts so that connections are not maintained indefinitely in the absence of data transfer. You can either avoid the timeouts by transferring some data (eg. the printing of dots which you've already found) or better yet you could restructure your code so that it runs in the background on the server and the client polls to determine when it has finished. The latter is generally accepted to be the better solution because it doesn't clog up the server with long-lived connections doing precious little.
There is of course a third option which is to optimise your code so that it produces results in a reasonably short time.
| [reply] |