Php 在symfony命令内启动线程时出现致命错误

Php 在symfony命令内启动线程时出现致命错误,php,multithreading,symfony,pthreads,Php,Multithreading,Symfony,Pthreads,我尝试在Symfony2命令中启动一个简单的线程(使用pthreads ext v3为PHP7创建)。但我想知道是否因为不可序列化的闭包(我在任何地方都不使用闭包)而导致错误 命令: <?php public function execute(InputInterface $input, OutputInterface $output) { $job = new JobThread(); $output->writeln('Starting thread...');

我尝试在Symfony2命令中启动一个简单的线程(使用pthreads ext v3为PHP7创建)。但我想知道是否因为不可序列化的闭包(我在任何地方都不使用闭包)而导致错误

命令:

<?php
public function execute(InputInterface $input, OutputInterface $output)
{
    $job = new JobThread();

    $output->writeln('Starting thread...');
    $job->start();

    $output->writeln('Waiting for thread to finish executing...');
    $job->join();

    $output->writeln('Thread finished');

}
如果我在命令上下文之外启动线程

$job = new ThreadJob();

echo 'Starting thread...' . PHP_EOL;
$job->start();

echo 'Waiting for thread to finish executing...' . PHP_EOL;
$job->join();

echo 'Thread finished' . PHP_EOL;
我得到了预期的输出:

Starting thread...
Waiting for thread to finish executing...
Run
End
Thread finished

故障点在哪里?

我不知道为什么会发生这种情况,但以下可能是一些提示:

这项工作:

$job->start(PTHREADS_INHERIT_ALL ^ PTHREADS_INHERIT_CLASSES);
如果这不起作用(其作用与在没有额外值的情况下调用start完全相同):


好的,这对空线程有效。但它将删除所有已加载的用户定义类:-(请参阅本文中的注释)
Starting thread...
Waiting for thread to finish executing...
Run
End
Thread finished
$job->start(PTHREADS_INHERIT_ALL ^ PTHREADS_INHERIT_CLASSES);
$job->start(PTHREADS_INHERIT_ALL);