title: Nodejs child process wont return data from python script to stdout
body: <p>I'm writing a simple web app to get a handle on how node child processes work.  Basically you enter your name into an angular frontend which passes the name to an express backend in a javascript object.  The backend passes the name as an argument to a simple python script as a command line argument using the child_process module.  Theres nothing wrong with the front end and the name gets successfully passed to the backend but when I call stdout on the python process it doesn't work.  There aren't any error messages.</p>
  
  <p>Heres the express code:</p>
  
  <pre><code>app.post('/api', (req, res, next) =&gt; {
    console.log(req.body.name);
  
    const spawn = require('child_process').spawn;
  
    const process = spawn('python3', ['./hello.py', req.body.name]);
  
    process.stdout.on('data', (data) =&gt; {
      console.log(data);
      res.status(200).json({greeting: data});
    });
  });
  </code></pre>
  
  <p>I put two console.log statements in the code to debug it.  The first one prints the data but the second one inside the stdout function isn't called at all.  The python script is in the same folder as the app.js express file so I'm pretty sure theres nothing wrong with the file path.</p>
  
  <p>Here's the python script:</p>
  
  <pre><code>import sys
  
  print('hello' + sys.argv[1])
  sys.stdout.flush()
  </code></pre>
  
  <p>When I run it in the command line it works exactly as expected but I included it anyway just in case.</p>