Skip to content

Commit d6904e9

Browse files
committed
Added a property for executing a command in coroutine environment.
1 parent c6b62b7 commit d6904e9

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

src/Command.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ abstract class Command extends SymfonyCommand
5050
*/
5151
protected $verbosity = OutputInterface::VERBOSITY_NORMAL;
5252

53+
/**
54+
* Execution in a coroutine environment.
55+
*
56+
* @var bool
57+
*/
58+
protected $coroutine = false;
59+
5360
/**
5461
* The mapping between human readable verbosity levels and Symfony's OutputInterface.
5562
*
@@ -363,6 +370,12 @@ protected function configure()
363370

364371
protected function execute(InputInterface $input, OutputInterface $output)
365372
{
366-
call([$this, 'handle']);
373+
if ($this->coroutine) {
374+
go(function () {
375+
call([$this, 'handle']);
376+
});
377+
return 0;
378+
}
379+
return call([$this, 'handle']);
367380
}
368381
}

0 commit comments

Comments
 (0)