运行此代码块时,
reasoner = new Reasoner({
type: 'local',
folder: 'csp_files'
});
console.log("solving Model");
reasoner.solve(Model, (err, stdout, stderr, isSatisfiable) => {
console.log("isSatisfiable");
console.log(isSatisfiable);
if (err) {
// manage error
console.log("model error");
future_response.return("model error");
} else {
// manage solution
console.log(stdout);
console.log(isSatisfiable);
future_response.return(stdout);
}
});
console.log("Model solved");
return future_response.wait();
从我已阅读的内容中,我应该找到一种重写stdout
的方法以支持更大的缓冲区长度,有人可以建议我该怎么做吗?我相信应该使用库spawn
,对吗?
我使用节点版本12.16.1和流星
答案 0 :(得分:1)
使用 child_process.exec 时需要使用和设置 maxBuffer 选项。来自 : documentation
它是 - Node 的 child_process 的 spawn() 和 exec() 之间的区别。当您希望子进程向 Node 返回大量二进制数据时使用 spawn(),当您希望子进程返回简单的状态消息时使用 exec()。