Skip to content
Permalink
Browse files

Disable progressbar in threaded mode

  • Loading branch information...
muglug committed May 30, 2019
1 parent 1321b44 commit 1774d4029b418073ef6e2f430df616f13208e95c
Showing with 8 additions and 19 deletions.
  1. +1 −0 src/Psalm/Internal/Fork/ForkTaskDoneMessage.php
  2. +7 −19 src/Psalm/Internal/Fork/Pool.php
@@ -8,6 +8,7 @@ class ForkTaskDoneMessage implements ForkMessage
/**
* @param mixed $data
* @psalm-suppress PossiblyUnusedMethod
*/
public function __construct($data)
{
@@ -130,11 +130,7 @@ public function __construct(
// Get the work for this process
$task_data_iterator = array_values($process_task_data_iterator)[$proc_id];
foreach ($task_data_iterator as $i => $task_data) {
$task_result = $task_closure($i, $task_data);
$task_done_message = new ForkTaskDoneMessage($task_result);
$serialized_message = base64_encode(serialize($task_done_message)) . PHP_EOL;
// don’t care if this message doesn’t get through
@fwrite($write_stream, $serialized_message);
$task_closure($i, $task_data);
}
// Execute each child's shutdown closure before
@@ -144,20 +140,7 @@ public function __construct(
// Serialize this child's produced results and send them to the parent.
$process_done_message = new ForkProcessDoneMessage($results ?: []);
$serialized_message = base64_encode(serialize($process_done_message)) . PHP_EOL;
$bytes_written = @fwrite($write_stream, $serialized_message);
if (strlen($serialized_message) !== $bytes_written) {
$retries = 0;
while (!$bytes_written && $retries < 10) {
++$retries;
usleep(100000);
$bytes_written = @fwrite($write_stream, $serialized_message);
}
if (strlen($serialized_message) !== $bytes_written) {
error_log('Could not send ForkProcessDoneMessage to parent process, terminating.');
exit(self::EXIT_FAILURE);
}
}
fwrite($write_stream, $serialized_message);
fclose($write_stream);
@@ -278,6 +261,11 @@ private function readResultsFromChildren()
// If the stream has closed, stop trying to select on it.
if (feof($file)) {
if ($content[intval($file)] !== '') {
error_log('Child did not send full message before closing the connection');
$this->did_have_error = true;
}
fclose($file);
unset($streams[intval($file)]);
}

0 comments on commit 1774d40

Please sign in to comment.
You can’t perform that action at this time.