我有一个像这样的...直接来自文档
my $proc = Proc::Async.new: ‘raku’, ‘script.raku’;
$proc.stdout.tap(-> $v { print "Output: $v" }, quit => { say 'caught exception ' ~ .^name });
$proc.stderr.tap(-> $v { print "Error: $v" });
my $promise = $proc.start;
Thread.start: { await $promise;}
sleep 30;
该脚本在 stdout 和 stderr 上生成数据。 但 它只打印一行.. 输出:一些东西
它停止打印信息...脚本产生更多的输出... 可能是什么问题?
最佳答案
您需要在程序末尾添加一个await $promise
,否则它可能会在您调用的程序完成运行之前退出。
更新(在 OP 编辑他的帖子之后)。
OP 还说关闭了 stackoverflow:
The full output is printed when the program ends.. with a considerable delay.
如果是这种情况,问题很可能出在被调用的程序上,它缓冲了它的 STDOUT(和可能的 STDERR),因此观察程序甚至无法提前访问它的输出。
调用 flush在被调用程序的适当句柄上可能会有所帮助。
关于linux - 通过 Proc::Async 执行的命令不是正确的 "tapped",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70286420/