Skip to content

Commit ebbed76

Browse files
authored
Merge pull request #101 from deliciousbrains/respond-to-pause-and-cancel-more-quickly
Ensure task processing cleanly pauses or cancels as soon as possible
2 parents d5ef95c + c36c9d2 commit ebbed76

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

classes/wp-background-process.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,8 @@ protected function handle() {
527527
// Let the server breathe a little.
528528
sleep( $throttle_seconds );
529529

530-
if ( $this->time_exceeded() || $this->memory_exceeded() ) {
531-
// Batch limits reached.
530+
// Batch limits reached, or pause or cancel request.
531+
if ( $this->time_exceeded() || $this->memory_exceeded() || $this->is_paused() || $this->is_cancelled() ) {
532532
break;
533533
}
534534
}
@@ -537,7 +537,7 @@ protected function handle() {
537537
if ( empty( $batch->data ) ) {
538538
$this->delete( $batch->key );
539539
}
540-
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() );
540+
} while ( ! $this->time_exceeded() && ! $this->memory_exceeded() && ! $this->is_queue_empty() && ! $this->is_paused() && ! $this->is_cancelled() );
541541

542542
$this->unlock_process();
543543

0 commit comments

Comments
 (0)