ActionScheduler_QueueRunner::do_batch() – Process a batch of actions pending in the queue.

You appear to be a bot. Output may be restricted

Description

Process a batch of actions pending in the queue.

Actions are processed by claiming a set of pending actions then processing each one until either the batch size is completed, or memory or time limits are reached, defined by @see $this->batch_limits_exceeded().

Usage

$int = ActionScheduler_QueueRunner::do_batch( $size, $context );

Parameters

$size
( int ) optional default: 100 – The maximum number of actions to process in the batch.
$context
( string ) optional – Optional identifer for the context in which this action is being processed, e.g. 'WP CLI' or 'WP Cron' Generally, this should be capitalised and not localised as it's a proper noun.

Returns

int The number of actions processed.

Source

File name: woocommerce/packages/action-scheduler/classes/ActionScheduler_QueueRunner.php
Lines:

1 to 22 of 22
  protected function do_batch( $size = 100, $context = '' ) {
    $claim = $this->store->stake_claim($size);
    $this->monitor->attach($claim);
    $processed_actions = 0;

    foreach ( $claim->get_actions() as $action_id ) {
      // bail if we lost the claim
      if ( ! in_array( $action_id, $this->store->find_actions_by_claim_id( $claim->get_id() ) ) ) {
        break;
      }
      $this->process_action( $action_id, $context );
      $processed_actions++;

      if ( $this->batch_limits_exceeded( $processed_actions ) ) {
        break;
      }
    }
    $this->store->release_claim($claim);
    $this->monitor->detach();
    $this->clear_caches();
    return $processed_actions;
  }
 

 View on GitHub View on Trac