Skip to content

Commit

Permalink
More parallel debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Nov 11, 2020
1 parent 1fd761d commit 95101a0
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Command/WorkerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$analysedFiles = array_fill_keys($analysedFiles, true);

$tcpConector = new TcpConnector($loop);
$tcpConector->connect(sprintf('127.0.0.1:%d', $port))->done(function (ConnectionInterface $connection) use ($container, $identifier, $analysedFiles, $tmpFile, $insteadOfFile): void {
$tcpConector->connect(sprintf('127.0.0.1:%d', $port))->done(function (ConnectionInterface $connection) use ($container, $identifier, $output, $analysedFiles, $tmpFile, $insteadOfFile): void {
$out = new Encoder($connection);
$in = new Decoder($connection, true, 512, 0, $container->getParameter('parallel')['buffer']);
$out->write(['action' => 'hello', 'identifier' => $identifier]);
$this->runWorker($container, $out, $in, $analysedFiles, $tmpFile, $insteadOfFile);
$this->runWorker($container, $out, $in, $output, $analysedFiles, $tmpFile, $insteadOfFile);
});

$loop->run();
Expand All @@ -149,6 +149,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
* @param Container $container
* @param WritableStreamInterface $out
* @param ReadableStreamInterface $in
* @param OutputInterface $output
* @param array<string, true> $analysedFiles
* @param string|null $tmpFile
* @param string|null $insteadOfFile
Expand All @@ -157,12 +158,14 @@ private function runWorker(
Container $container,
WritableStreamInterface $out,
ReadableStreamInterface $in,
OutputInterface $output,
array $analysedFiles,
?string $tmpFile,
?string $insteadOfFile
): void
{
$handleError = static function (\Throwable $error) use ($out): void {
$handleError = static function (\Throwable $error) use ($out, $output): void {
$output->writeln(sprintf('Error: %s', $error->getMessage()));
$out->write([
'action' => 'result',
'result' => [
Expand Down

0 comments on commit 95101a0

Please sign in to comment.