function background_process_http_request_process in Background Process 8
Same name and namespace in other branches
- 6 background_process.module \background_process_http_request_process()
- 7.2 background_process.http.inc \background_process_http_request_process()
- 7 background_process.module \background_process_http_request_process()
Implements Process multiple http requests.
1 call to background_process_http_request_process()
- background_process_determine_default_service_host in ./
background_process.module - Implements to Determine host for current installation.
File
- ./
background_process.module, line 1217 - This module implements a framework for calling funtions in the background.
Code
function background_process_http_request_process(&$results, $options = []) {
$options += [
'timeout' => 30,
'interval' => 0.01,
'limit' => 0,
];
$interval = $options['interval'] * 1000000;
$expire = time() + $options['timeout'];
while ($results && time() < $expire) {
$cnt = 0;
$data_ready = FALSE;
foreach ($results as &$result) {
if (isset($result->code)) {
continue;
}
background_process_http_request_get_response($result);
$data_ready = $data_ready || $result->data_ready ? TRUE : FALSE;
$cnt++;
if ($options['limit'] && $cnt >= $options['limit']) {
break;
}
}
if (!$cnt) {
break;
}
if (!$data_ready) {
usleep($interval);
}
}
}