Perl: the Markov chain saw | |
PerlMonks |
Delayed writesby SpaceAce (Beadle) |
on Oct 28, 2002 at 17:58 UTC ( [id://208564]=perlquestion: print w/replies, xml ) | Need Help?? |
SpaceAce has asked for the wisdom of the Perl Monks concerning the following question:
I feel boneheaded asking this, because I am probably overlooking the obvious, but it's bugging me.
I have written a script that runs from a webserver and is controlled/executed through the browser. Because of the length of time that can be involved in running the script from beginning to end, it forks off and sends a simple "The program is running" message to the user. As the script is running, it logs its actions to a file that can be viewed from the script's control panel. The idea is that the user can check the log every once in a while to monitor progress and see when the script has completed execution. The problem is, the log is not being written in anything even approaching realtime. All the writing seems to be getting done in 4096 byte increments. When I have the script output text directly to the browser, I experience no such delays. All I can think of is $|, but I have that set to a positive integer (1). I am not flocking the file (I had been, but both flock, 1 and flock, 2 resulted in the user having to wait for the script to run its course before viewing the log. Right now, I am dancing around the problem by having the program close and re-open the log file at the beginning of each loop iteration but that seems like a silly way to go. What's really driving me crazy is I used a nearly identical fork/log setup for a program in the past and it worked fine. Now I can't find that code anywhere, so I can't compare it with my current project. It's this part that leads me to believe I am overlooking some glaringly obvious point. The problem is hardly fatal, but I hate not understanding what my program is doing. Any information on how to fix this would be appreciated. Thanks, SpaceAce
Back to
Seekers of Perl Wisdom
|
|