You are here

function feedapi_cron_time in FeedAPI 6

Same name and namespace in other branches
  1. 5 feedapi.module \feedapi_cron_time()

Check for time limits in cron processing.

Return value

Number of seconds left, zero if none.

2 calls to feedapi_cron_time()
feedapi_cron in ./feedapi.module
Implementation of hook_cron().
_feedapi_invoke_refresh in ./feedapi.module
Helper function for feedapi_invoke(). Refresh the feed, call the proper parsers and processors' hooks. Don't call this function directly, use feedapi_refresh() instead.

File

./feedapi.module, line 742
Handle the submodules (for feed and item processing) Provide a basic management of feeds

Code

function feedapi_cron_time() {
  static $time_limit;
  if (!$time_limit) {
    $max_exec_time = ini_get('max_execution_time') == 0 ? 120 : ini_get('max_execution_time');
    $time_limit = time() + variable_get('feedapi_cron_percentage', 15) / 100 * $max_exec_time;

    // However, check for left time, maybe some other cron processing already occured
    $cron_semaphore = variable_get('cron_semaphore', 0);
    if ($cron_semaphore) {
      $time_limit = min($time_limit, $cron_semaphore + $max_exec_time);
    }
    timer_start('feedapi_cron');
  }
  return max($time_limit - time(), 0);
}