Skip to content

Commit 6596161

Browse files
committed
Fix StartCondition::isCanceled()
1 parent 386224f commit 6596161

File tree

4 files changed

+19
-9
lines changed

4 files changed

+19
-9
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
### master
22

3+
- Fix `StartCondition::isCanceled()` when a previous process has been canceled
4+
35
### [0.7.2](../../compare/0.7.1...0.7.2) - 2022-03-08
46

57
- Fix start ready processes when maximum paralell processes is not configured or value is `null`

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"require-dev": {
2020
"ext-simplexml": "*",
2121
"phpunit/phpunit": "9.5.*",
22-
"symfony/var-dumper": "5.3.*"
22+
"symfony/var-dumper": "5.4.*"
2323
},
2424
"autoload": {
2525
"psr-4": {

src/Console/Application/ParallelProcessesApplication.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,29 +177,31 @@ protected function startProcesses(): self
177177
protected function waitProcessesTermination(OutputInterface $output): self
178178
{
179179
$terminated = 0;
180-
while ($terminated !== count($this->getProcesses())) {
180+
while ($terminated < $this->getProcesses()->count()) {
181181
if ($this->isCanceled()) {
182182
break;
183183
}
184184

185185
$terminated = 0;
186186

187+
$this
188+
->startReadyProcesses()
189+
->defineCanceledProcesses();
190+
187191
foreach ($this->getProcesses()->toArray() as $process) {
188192
if ($process->isCanceled() || $process->isTerminated()) {
189193
$terminated++;
190194
}
191195
}
192196

193-
$this
194-
->startReadyProcesses()
195-
->defineCanceledProcesses();
196-
197197
$this
198198
->getTheme()
199199
->resetOutput($output, $this->getProcesses())
200200
->outputProcessesState($output, $this->getProcesses());
201201

202-
usleep($this->getRefreshInterval());
202+
if ($terminated < $this->getProcesses()->count()) {
203+
usleep($this->getRefreshInterval());
204+
}
203205
}
204206

205207
return $this;

src/Process/StartCondition.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,21 @@ public function isCanceled(): bool
106106
$return = false;
107107

108108
foreach ($this->getProcessesSuccessful()->toArray() as $successfulProcess) {
109-
if ($successfulProcess->isTerminated() && $successfulProcess->isSuccessful() === false) {
109+
if (
110+
($successfulProcess->isTerminated() && $successfulProcess->isSuccessful() === false)
111+
|| $successfulProcess->isCanceled()
112+
) {
110113
$return = true;
111114
break;
112115
}
113116
}
114117

115118
if ($return === false) {
116119
foreach ($this->getProcessesFailed()->toArray() as $failedProcess) {
117-
if ($failedProcess->isTerminated() && $failedProcess->isSuccessful()) {
120+
if (
121+
($failedProcess->isTerminated() && $failedProcess->isSuccessful())
122+
|| $failedProcess->isCanceled()
123+
) {
118124
$return = true;
119125
break;
120126
}

0 commit comments

Comments
 (0)