I am running a python script through a node child_process. This python script downloads a file to disk then returns the filename to node. The problem I'm having is that the file saved by python doesn't appear in my files directory until after the node process closes (by throwing an error since it is trying to read this file saved by python). I am not sure how to get python to "instantly" save the file so my node process can then read it.
Node code:
var sent = false;
const CP = require("child_process");
var process = CP.spawn('python', ["../pyScripts/download.py", vid_url]);
process.stdout.on('data', function(data){
console.log("recieved data")
if(sent === false){
sent = true
process.kill('SIGINT');
doStuffWithFile(`${data.toString()}.mp4`);
}
});
Python code:
#*code that grabs file bytes*
with open(f'{filename}.mp4', "wb") as out:
out.write(vid_bytes)
print(filename)