I am using batch api for processing the operations. In my operation I am sending xml request to different-different external server and waiting for its response, after getting its response I am processing it.

But sometimes it is taking too much time. In case where it is taking too much time (If response is taking more than 2 minute). I want to process the next operation.

I checked batch_set but could found the way. How to implement it?

closed as unclear what you're asking by kiamlaluno Aug 9 at 10:38

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    This is probably more of a PHP than Drupal question, but could you edit the question to provide the code that's making the external request? – Clive Mar 10 '15 at 15:27

I have achieved this using php.

Here is the sample code

$operations[] = array('batch_function_1');
$operations[] = array('batch_function_2');

$batch = array(
  'title' => t('Processing'),
  'operations' => $operations,
  'init_message' => t('Please wait processing is starting.....'),
  'progress_message' => t('Processed @current out of @total.'),
  'error_message' => t('Processing has encountered an error.'),
  'finished' => 'processing_finished',


In case of soap I achieved using default_socket_timeout

function batch_function_1 () {
  ini_set("default_socket_timeout", $time);
    $client = new SoapClient($path_to_wsdl));
  catch(Exception $e) {
    dpm('Timeout'); // echo 'Timeout';                                                                                                        

And timeout when using exec.

function batch_function_2 () {
  // $command : Which needs to be executed for communicating with server.                                                                       
  exec("timeout {$time} {$command}", $output);

I also tried the set_time_limit which was not working with batch api.

Not the answer you're looking for? Browse other questions tagged or ask your own question.