in reply to Re: Long Process Waits Until End to Display Results
in thread Long Process Waits Until End to Display Results

I think the issue is in the $cache->set call. What type of object is $cache?

It's a Cache::FileCache object as described in the paper by Merlyn referenced earlier in the thread.

Basically the cgi keeps calling itself every five seconds, and when it revisits itself it prints the contents of the cache object. So I store all output of the script in this cache object.

Once the long process completes, all its output goes into the cache object as it should. It's just that it takes until it completes to see what's going on.

CT

Charles Thomas
Madison, WI
  • Comment on Re^2: Long Process Waits Until End to Display Results

Replies are listed 'Best First'.
Re^3: Long Process Waits Until End to Display Results
by traveler (Parson) on Dec 10, 2004 at 00:22 UTC
    OK. merlyn's article deals with how to save the information between invocations to a CGI (using a persistent cache and session key to get the data back). You want to do something different. You want real timeish results. That's different.

    You do not need to put the data in the cache; in fact, it is what is storing or buffering the output. You need to set $| to 1 and send the data directly to the user. One big issue, though, is that browsers sometimes "timeout": as noted above if they don't see data in n seconds, they disconnect. I have solved this in the past using timeouts. For now, I'd just write the data directly to the browser with $|=1 and without the cache, and see what happens.

    You could use a solution like merlyn's by extending the key to be $session-$line and then retreiving each line individually.

      Seems kind of a Catch 22 situation. I need the caching for the reason you allude to. The process which is being buffered can take four hours to complete, so that's why I'm doing the caching and 5-second refreshing, to keep the browser from timing out.

      But it's that caching that's keeping me from seeing real-time results.

      You could use a solution like merlyn's by extending the key to be $session-$line and then retreiving each line individually.

      Can you expand on this idea? I'm not sure how this would work. Wouldn't I lose the ability to display everything that had happend so far and only see the single line that was currently being displayed? Maybe some sample code (if you know any) would be helpful.

      CT

      Charles Thomas
      Madison, WI
        I need the caching for the reason you allude to. The process which is being buffered can take four hours to complete, so that's why I'm doing the caching and 5-second refreshing, to keep the browser from timing out.

        I did not get that from your initial post. It might be helpful to see more of your code, particularly the part you use to processess the cache and send the info to the user.