Re: Odp: [PHP-WIN] RE:escape loop on timeout

From: Date: Wed, 23 May 2001 23:44:26 +0000
Subject: Re: Odp: [PHP-WIN] RE:escape loop on timeout
References: 1 2  Groups: php.windows 
Request: Send a blank email to php-windows+get-7899@lists.php.net to get a copy of this message
I have a multi dimensional array dim[0] are URLs dim[1] is supposed to be the description which i am creating by fetching the page remotely.. often as you said the page wont come through for some reason .. in such cases the script hangs.. .. Piotr Plusa wrote: > Have you got any idea what to do when you want to measure the time but not > in the loop? > > Case: you want to limit the time of reading from an open socket (fread), the > other side doesn't answer, you wait and wait... > > Piotr Plusa > > ----- Wiadomosc oryginalna ----- > Od: "Brendan" <bgogarty@postoffice.sandybay.utas.edu.au> > Do: <php-windows@lists.php.net> > Wyslano: 23 maja 2001 01:54 > Temat: [PHP-WIN] RE:escape loop on timeout > > > > > > > Zak Greant wrote: > > > > > Johan Lundqvist wrote: > > > > This is a way of doing it: > > > > > > > > $s = time() + 10; > > > > for ($i = time(); $i <= $s; $i++) { > > > > print $i; > > > > } > > > > > > > > Will run for about ten seconds... > > > > > > Did you leave a bit of code out? > > > In most cases, this will run for only a few milliseconds. :) > > > > > > Try something like this instead: > > > > > > $timeout = 1; // Timeout in seconds > > > $start_time = time(); // Get the current time > > > > > > for ($x=0; $x < 1000000000; ++$x) { > > > > > > /* > > > // Check if we have gone over the time limit > > > // Only check every 1000 loops - this keeps > > > // us from chewing run time by checking the time > > > // all the time :) > > > */ > > > if ( (0 === ($x % 1000)) && (time () - $start_time) > $timeout) > > > break; > > > > > > echo ($x, '<br>'); > > > } > > > > > > --zak > > > > > > > ---------------- > > > > Thanks guys > > > > sorry about the delay .. I am in Australia.. > > checking the time each loop would only work if the loops complete > correctly > > .. if the process locks mid loop php wont reach the criterion break > because > > it deals with each command linearly. ie > > > > for (x=0;x!="array full";x++) > > dothisfunction(x); > > if ( (0 === ($x % 1000)) && (time () - $start_time) > $timeout) > > break; > > etc > > > > if dothisfunction() locks up wont the entire script freeze? > > > > maybe I am wrong.. > > > > what I am after is something like alert() in Perl or the 'on error resume > > next' in ASP which runs externally to the loop and breaks to the next > > instance if it is taking too long... > > any ideas? > > cheers! > > > > > > > > > > > > > > > > > > -- > > PHP Windows Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > > For additional commands, e-mail: php-windows-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net > For additional commands, e-mail: php-windows-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.windows (#7899) next »