admin管理员组文章数量:1291023
I'm beginer of electron, and I learned I can execute external program with spawn function. But, when I execute external program, I can't see output data of the program immediately.
This is my external python program. You can see it's a simple program printing "Tick" and saving it to the file. And it works fine, when I execute it manually. I can see the "Tick" every each second.
import time
while True:
with open("tick.txt", "a") as f:
f.write("Tack")
f.close()
print("Tick")
time.sleep(1)
But, when I execute it by electron spawn() with following code, I can not see "Tick" on the VS-Code terminal.
function ExecuteTick()
{
try {
console.log("Executing Tick");
const child_process = spawn(
"python",
[
"../converter/tick.py"
]);
child_process.stdout.on('data', (data) => {
console.log(data.toString());
});
child_process.stderr.on('data', (data) => {
console.error("Tick-Error: " + data);
});
child_process.on('close', (code) => {
console.log("Tick-End: " + code);
});
}catch(err){
console.error("Error on executing Tick - " + err);
}
}
I believe this Tick program run properly in the background. Because I can see "Tack" from the 'tick.txt' file.
So, my problem is that, When I execute Tick program by electron spawn(), I can not see stdout from the Tick program in realtime, even though it runs properly.
Could you give me some advice for this problem? Thanks.
本文标签: In case spawn of electronI can39t see output of process in realtimeStack Overflow
版权声明:本文标题:In case spawn of electron, I can't see output of process in realtime - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741458748a2379909.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论