Skip to content

Commit

Permalink
Merge pull request #101 from deliciousbrains/respond-to-pause-and-can…
Browse files Browse the repository at this point in the history
…cel-more-quickly

Ensure task processing cleanly pauses or cancels as soon as possible
  • Loading branch information
AhmedTheGeek committed Jul 18, 2023
2 parents d5ef95c + c36c9d2 commit ebbed76
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions classes/wp-background-process.php
Expand Up @@ -527,8 +527,8 @@ protected function handle() {
// Let the server breathe a little.
sleep( $throttle_seconds );

if ( $this->time_exceeded() || $this->memory_exceeded() ) {
// Batch limits reached.
// Batch limits reached, or pause or cancel request.
if ( $this->time_exceeded() || $this->memory_exceeded() || $this->is_paused() || $this->is_cancelled() ) {
break;
}
}
Expand All @@ -537,7 +537,7 @@ protected function handle() {
if ( empty( $batch->data ) ) {
$this->delete( $batch->key );
}
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() && ! $this->is_paused() && ! $this->is_cancelled() );

$this->unlock_process();

Expand Down

0 comments on commit ebbed76

Please sign in to comment.