Async HTTP Request Queue Runner
Overview
ActionScheduler_AsyncRequest_QueueRunner extends WP_Async_Request to run the queue via a non-blocking HTTP request. This provides a fallback and a way to process actions when WP-Cron is delayed.
When async requests are dispatched
The main queue runner calls maybe_dispatch_async_request() during shutdown:
- It only runs in the admin context (
is_admin()). - It uses a lock to ensure the async runner is only triggered once per lock duration.
- It avoids expensive DB checks if possible.
Locking details are in locking.md.
Dispatch flow
ActionScheduler_QueueRunner::maybe_dispatch_async_request()verifies:is_admin()ActionScheduler::lock()->is_locked( 'async-request-runner' )is falseActionScheduler::lock()->set( 'async-request-runner' )succeeds
- If all checks pass, it calls
$this->async_request->maybe_dispatch().
Async request handling
ActionScheduler_AsyncRequest_QueueRunner::handle():
- Fires
do_action( 'action_scheduler_run_queue', 'Async Request' )to run a queue withAsync Requestcontext. - Sleeps briefly to avoid MySQL crashes when chaining async requests:
action_scheduler_async_request_sleep_seconds(default5)
- Calls
maybe_dispatch()again to chain another request if needed.
Allowing or disabling async requests
ActionScheduler_AsyncRequest_QueueRunner::allow() permits dispatch only if:
action_scheduler_run_queuehas a hooked handler- The runner does not already have maximum concurrent batches
- There are pending actions due in the store
Then it passes the decision through:
action_scheduler_allow_async_request_runner(bool)
Hooks & Filters
Actions
action_scheduler_run_queue(invoked with contextAsync Request)
Filters
action_scheduler_allow_async_request_runneraction_scheduler_async_request_sleep_seconds