function BackgroundProcess::dispatch in Background Process 7
Same name and namespace in other branches
- 8 background_process.class.php \BackgroundProcess::dispatch()
- 6 BackgroundProcess.class.php \BackgroundProcess::dispatch()
- 7.2 background_process.inc \BackgroundProcess::dispatch()
1 call to BackgroundProcess::dispatch()
File
- ./
BackgroundProcess.class.php, line 184 - Class for handling background processes.
Class
- BackgroundProcess
- BackgroundProcess class.
Code
function dispatch() {
$this
->sendMessage('dispatch');
$handle = rawurlencode($this->handle);
$token = rawurlencode($this->token);
list($url, $headers) = background_process_build_request('bgp-start/' . $handle . '/' . $token, $this->service_host);
background_process_set_service_host($this->handle, $this->service_host);
$options = array(
'method' => 'POST',
'headers' => $headers,
);
$result = background_process_http_request($url, $options);
if (empty($result->error)) {
$this->connection = $result->fp;
_background_process_ensure_cleanup($this->handle, TRUE);
return TRUE;
}
else {
background_process_remove_process($this->handle);
watchdog('bg_process', 'Could not call service %handle for callback %callback: !error', array(
'%handle' => $this->handle,
'%callback' => _background_process_callback_name($this->callback),
'!error' => print_r($result, TRUE),
), WATCHDOG_ERROR);
// Throw exception here instead?
return NULL;
}
return FALSE;
}