PHP 在shell 中执行一个python,不等待执行但会得到结果

PHP execute a python in shell, do not wait for executing but will get the result

我一直在寻找答案,但所有的问题都指向 PHP 脚本不等待输出,也不取回输出...

我正在做的是一个简单的php网页,它执行一个python脚本来查询附近的蓝牙设备并显示结果。蓝牙查询 python 确实占用了一些时间到 运行,因此当我从 PHP 执行 python 脚本时,整个网页都在等待 [=25= 的输出] 并挂起。

是否有可能首先显示页面的所有其余部分 - 页眉、页脚等,然后以某种方式将 shell 结果弹出回网页?非常感谢!

尝试 运行 Iframe 中的脚本或通过 Ajax 请求。

<html>
    <header>
       <title>...</title>
    </header>
   <body>
      <header>...</header>
      <iframe src="bluetoothscript.php"></iframe>
      <footer>...</footer>
   </body>
</html>