title: How to avoid php timeout while running this loop?
body: <p>I'm writing a function that supposed to update the price for all woocommerce products.. the price data i will get from amazon using amazon api which has a certain x query per second limit thats why i will have to sleep on each loop. Im planing to run that function as a cron job. the below function is just an example for what im planing to do so please ignore he missing variable declaration etc..</p>
  
  <p>I understand that i can increase the php timeout limit but im imagining what if i have hundreads or thousand of products and on each query i will have to to sleep for a while to avoid query throtling so to update all products it can take hours in this case so im wondering what is the best and easiest solution to keep that function looping for hours and stop after reaching the last id on $products_ids array?</p>
  
  <pre><code>function text(){
    foreach ($products_ids as $products_id) {
    //apm_single_lookup func do an API call which has max query/sec limit thats why i added the next sleep
    $lookup_data = apm_single_lookup($eu_asin, $amazon_domain);   
    update_post_meta($products_id, $field_name, esc_attr($lookup_data['price']));
    sleep(1);
    }
  }
  </code></pre>