Re: Looking for ways to prevent timeout

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/5/07, Jochem Maas <jochem@xxxxxxxxxxxxx> wrote:
> Jon Westcot wrote:
> > Hi Jochem:
> >
> >     Thanks for the suggestion.  Not to sound more dense than I already seem,
> > but how do I do this?
>
> by calling the function somewhere near the top of your script?
>
> ignore_user_abort();
>
> How do I tell the browser that something is still
> > running?  I'm issuing a flush() after every 1000 records along with echoing
> > a textual status update.  Should I do it more frequently, say every 100
> > records?
>
> I have never trusted that method of keeping the browser from thinking the
> response is not forthcoming but it's better than nothing.
>
> >
> >     I'm really struggling with this concept here, and I appreciate the help
> > that everyone is giving me!
>
> dont forget to read the manuAl AND the user comments on the pages relevant to
> the functions you are using to tackle the problem
>
> >
> >     Jon
> >
> > ----- Original Message -----
> > From: "Jochem Maas" <jochem@xxxxxxxxxxxxx>
> > To: "Jon Westcot" <jon@xxxxxxxxxxx>
> > Cc: "PHP General" <php-general@xxxxxxxxxxxxx>
> > Sent: Sunday, November 04, 2007 7:28 PM
> > Subject: Re:  Looking for ways to prevent timeout
> >
> >
> >> Jon Westcot wrote:
> >>> Hi all:
> >>>
> >>>     I'm hoping to find a solution to the problem I'm having with my
> > script timing out while inserting records into a table.
> >>>     Overall, the process is pretty fast, which is impressive, but when
> > it gets to the 22,000 to 23,000 record mark, it seems to time out.  I've had
> > it get up over 26,000 so far, but nothing better than that.  And I only need
> > to process around 30,000 right now.
> >>>     I've tried setting max_execution_time to 1800; no improvement.  The
> > value for max_input_time is -1, which, if I understood it correcctly, is the
> > same as saying no limit.  And I've tried calling set_time_limit() with both
> > 0 and with 360, none of which seemed to help.
> >>>     Is there ANY WAY to increase the amount of time I can use when
> > running a script that will work?  I've tried everything I can find in the
> > PHP manual.
> >>>     Any help you can provide will be greatly appreciated!
> >> http://php.net/ignore_user_abort will help, but nothing will stop you
> > hitting a max execution time.
> >> but my guess is your not hitting the max but rather the browser is killing
> > the connection because it's
> >> had no response fom your script and as a result apache is killing your
> > script as it thinks it's no longer
> >> needed (i.e. the browser no longer wants the response).
> >>
> >>>         Jon
> >>>
> >>
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

    Does it absolutely need to be run via the browser?  Can it be run
from the CLI instead?  Maybe even something like this:

    ######### PART 1 #########
<?
// script1.php
/* Do whatever you need
this script to do, including
passing variables, et cetera.*/

// For example:
$today = date("m/d/Y");

$fruit[] = "apple";
$fruit[] = "banana";
$fruit[] = "cherry";

function arr2str($arr,$delimiter=',') {
        for($i=0;$i<count($arr);$i++) {
                if($i > 0 && $i < count($arr)) {
                        $str .= ",";
                }
                $str .= $arr[$i];
        }
        return $str;
}

// This would have to be in an exact order if you
// want to name these variables in the next script.
exec('`which php` cli_from_web2.php '.$today.' '.arr2str($fruit),$ret);
?>


    ######### PART 2 #########
<?
// script2.php

// Disable any attempt to stop the script,
// short of a ps kill or equivalent.
ignore_user_abort();

// Remember, if you want to name the variables,
// they have to either be distinguished via the
// CLI or kept in an exact, expected order.

for($i=1;$i<count($argv);$i++) {
// Start with 1 because 0 is script name
        echo $argv[$i]."\n"; // Output to stdio to demo
}
?>


-- 
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Give a man a fish, he'll eat for a day.  Then you'll find out he was
allergic and is hospitalized.  See?  No good deed goes unpunished....

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux