Skip to content

Commit

Permalink
[v0.1.5] fix infinte child process creation when there is nothing to …
Browse files Browse the repository at this point in the history
…proceed (no result from criteria/collection)
  • Loading branch information
Benjamin Calef committed Dec 8, 2023
1 parent 9c1e3f1 commit 8a6e0e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Model/Processor/ForkedProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ private function handleSingleChildProcesses(): void
$currentPage = 1;
$childProcessCounter = 0;
$totalPages = $this->itemProvider->getTotalPages();
if ($totalPages <= 0) {
$this->logger->info('There is nothing to process');
$this->running = false;
return;
}

while ($currentPage <= $totalPages) {
// create fork
Expand Down Expand Up @@ -107,6 +112,11 @@ private function handleMultipleChildProcesses(): void
$childProcessCounter = 0;
$childPids = [];
$totalPages = $this->itemProvider->getTotalPages();
if ($totalPages <= 0) {
$this->logger->info('There is nothing to process');
$this->running = false;
return;
}

while ($currentPage <= $totalPages) {
// manage children
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "zepgram/module-multi-threading",
"description": "This module is a powerful tool for developers who want to process large data sets in a short amount of time",
"type": "magento2-module",
"version": "0.1.4",
"version": "0.1.5",
"authors": [
{
"name": "Benjamin Calef",
Expand Down

0 comments on commit 8a6e0e6

Please sign in to comment.