• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer
WooCommerce a2z

WooCommerce a2z

WooCommerce

  • Home
  • Plugins
  • Blocks
  • Shortcodes
  • APIs
  • Classes
  • Files
  • Hooks
  • Sitemap
  • Blog
Home / APIs / ActionScheduler_QueueRunner::maybe_dispatch_async_request() – Check if we should dispatch an async request to process actions.

You appear to be a bot. Output may be restricted

Description

Check if we should dispatch an async request to process actions.

This method is attached to 'shutdown', so is called frequently. To avoid slowing down the site, it mitigates the work performed in each request by:

  1. checking if it's in the admin context and then
  2. haven't run on the 'shutdown' hook within the lock time (60 seconds by default)
  3. haven't exceeded the number of allowed batches.

The order of these checks is important, because they run from a check on a value:

  1. in memory – is_admin() maps to $GLOBALS or the WP_ADMIN constant
  2. in memory – transients use autoloaded options by default
  3. from a database query – has_maximum_concurrent_batches() run the query
  4. $this->store->get_claim_count() to find the current number of claims in the DB.

If all of these conditions are met, then we request an async runner check whether it should dispatch a request to process pending actions.

Usage

ActionScheduler_QueueRunner::maybe_dispatch_async_request();

Parameters

Returns

void

Source

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


Lines:

1 to 8 of 8
  public function maybe_dispatch_async_request() {
    if ( is_admin() && ! ActionScheduler::lock()->is_locked( 'async-request-runner' ) ) {
      // Only start an async queue at most once every 60 seconds
      ActionScheduler::lock()->set( 'async-request-runner' );
      $this->async_request->maybe_dispatch();
    }
  }
 

 View on GitHub View on Trac

Published: 6th April 2020 | Last updated: 6th May 2020

Primary Sidebar

Information

Function name: ActionScheduler_QueueRunner::maybe_dispatch_async_request
Class ref: ActionScheduler_QueueRunner
Plugin ref: WooCommerce
Version: 5.2.2
Sourcefile: packages/action-scheduler/classes/ActionScheduler_QueueRunner.php
File ref: packages/action-scheduler/classes/ActionScheduler_QueueRunner.php
Deprecated?: No
API Letters: A,D,M,Q

Footer

WooCommerce a2z
WooCommerce a2z
WooCommerce
WordPress 5.7.1
WordPress a2z
WordPress core a2z
Genesis Theme Framework a2z
Jetpack a2z
WordPress develop tests
Easy Digital Downloads a2z
WooCommerce a2z
Yoast SEO a2z
WordPress Blocks

Site:  woocommerce.wp-a2z.org
© Copyright WooCommerce a2z 2014-2021. All rights reserved.


Website designed and developed by Herb Miller
Proudly powered by WordPress and oik plugins

  • Home
  • Blog
  • Sitemap
  • Sites