Skip to content

Commit 8a6e0e6

Browse files
author
Benjamin Calef
committed
[v0.1.5] fix infinte child process creation when there is nothing to proceed (no result from criteria/collection)
1 parent 9c1e3f1 commit 8a6e0e6

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

Model/Processor/ForkedProcessor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ private function handleSingleChildProcesses(): void
6969
$currentPage = 1;
7070
$childProcessCounter = 0;
7171
$totalPages = $this->itemProvider->getTotalPages();
72+
if ($totalPages <= 0) {
73+
$this->logger->info('There is nothing to process');
74+
$this->running = false;
75+
return;
76+
}
7277

7378
while ($currentPage <= $totalPages) {
7479
// create fork
@@ -107,6 +112,11 @@ private function handleMultipleChildProcesses(): void
107112
$childProcessCounter = 0;
108113
$childPids = [];
109114
$totalPages = $this->itemProvider->getTotalPages();
115+
if ($totalPages <= 0) {
116+
$this->logger->info('There is nothing to process');
117+
$this->running = false;
118+
return;
119+
}
110120

111121
while ($currentPage <= $totalPages) {
112122
// manage children

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "zepgram/module-multi-threading",
33
"description": "This module is a powerful tool for developers who want to process large data sets in a short amount of time",
44
"type": "magento2-module",
5-
"version": "0.1.4",
5+
"version": "0.1.5",
66
"authors": [
77
{
88
"name": "Benjamin Calef",

0 commit comments

Comments
 (0)