15 second time out - "batchifying" my lengthy task not helping
sneakyimp Jun 10, 2010 6:48 PMI have a highly intensive benchmark/testing chore and I'm getting the 15-second timeout error despite my best efforts to keep my script running.
Basically I'm making about 1.2 million remote procedure calls (RPCs) over a socket and want to check the results of these rpcs.
I can make the calls just fine. The problem I'm having is verifying the results of all these calls once the loop is complete.
Once the calls have all been sent, my flash movie moves to frame 7 which initializes a bunch of variables that I need for my RPC checking loop.
Frame 8 does all the work. The first thing it does is stop the playhead for my main movie. Then it sets up a timer to wait for minute or two until any straggling RPC responses come in. [It's been my experience that these are likely to straggle in for several minutes when I'm really pushing the server hard.]
If the timer gets too high, the [b]checkResponse[/b] function returns and the playhead moves to frame 9 which checks to see if I've checked all the RPCs. If not, the playhead returns to from 8 which skips the timer this time and starts checking immediately.
The output I'm getting ends up like this:
elapsed time:4985
elapsed time:4985
Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at flash_fla::MainTimeline/checkResponses()
at flash_fla::MainTimeline/frame8()
at flash.display::MovieClip/gotoAndPlay()
at flash_fla::MainTimeline/runDelayedResponseCheck()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
As you can see, my timer only reaches about 5 seconds before the timeout exception occurs. I've been searching for something in AS3 to return the current script execution time, but am not having much luck.
Here's an abbreviated bit of code from frame 8
trace('entered Frame 8');
this.stop();
// if the checks have already started, skip the postSendDelay
if (checksStarted) {
// if we've already started the check, continue immediately
checkResponses();
this.gotoAndPlay(9);
} else {
// otherwise, set up a timer to wait for the RPCs to finish rolling in
var checkTimer:Timer = new Timer(postSendDelay, 1);
checkTimer.addEventListener(TimerEvent.TIMER, runDelayedResponseCheck);
checkTimer.start();
}
function runDelayedResponseCheck(evt:Event):void {
checkResponses();
this.gotoAndPlay(9);
}
function checkResponses():Boolean {
checksStarted = true;
var startDate:Date = new Date();
for (var thd=startThd; thd <= threads_count; thd++) {
for (var itr=startItr; itr <= iteration_count; itr++) {
// check our execution time in case we running long
var now:Date = new Date();
var elapsedTime:Number = now.valueOf() - startDate.valueOf();
trace('elapsed time:' + elapsedTime);
if ( elapsedTime > timeOut) {
trace('time limit reached, going to next frame');
startThd = thd;
startItr = itr;
return false; // return and move on to next frame
}
// check the current RPC
// LENGTHY CHECK BLAH BLAH BLAH
} // foreach iteration
startItr = 1;
} // foreach thread
checksComplete = true;
trace('checkResponse ran to completion');
return true;
} // checkResponses()



