Skip to content

Commit e738c3a

Browse files
authored
Add support for LoopMax for ConsoleApplicationRunner (#153)
1 parent 78fe628 commit e738c3a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/ConsoleApplicationRunner.php

+8-1
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,24 @@
1414
class ConsoleApplicationRunner implements RunnerInterface
1515
{
1616
private $handler;
17+
private $loopMax;
1718

18-
public function __construct(Application $application)
19+
public function __construct(Application $application, int $loopMax = 1)
1920
{
2021
$this->handler = new ConsoleApplicationHandler($application);
22+
$this->loopMax = $loopMax;
2123
}
2224

2325
public function run(): int
2426
{
2527
$lambda = LambdaClient::fromEnvironmentVariable('symfony-runtime-console');
2628

29+
$loops = 0;
2730
while (true) {
31+
if (++$loops > $this->loopMax) {
32+
return 0;
33+
}
34+
2835
/*
2936
* In case the execution failed, we force starting a new process. This
3037
* is because an uncaught exception could have left the application

src/Runtime.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private function tryToFindRunner(?object $application)
9494
}
9595

9696
if ($application instanceof Application) {
97-
return new ConsoleApplicationRunner($application);
97+
return new ConsoleApplicationRunner($application, $this->options['bref_loop_max']);
9898
}
9999

100100
return parent::getRunner($application);

0 commit comments

Comments
 (0)