title: call nodejs and python asynchronously
body: <p>everybody, </p>
  
  <p>i want to call a python script asynchronously in my node script. I use "python-shell" for this. </p>
  
  <p>My problem is that node executes its own code first and then the python script. I need the python script data during runtime. </p>
  
  <p>That means :</p>
  
  <pre><code>let {PythonShell} = require('python-shell');
  let message;
  
  PythonShell.run('python.py',null,function(err,res){
  if(err) throw err;
  message =res;
  console.log("1",res);
  }
  console.log("2",{message});
  </code></pre>
  
  <p>Output:
  <code>=&gt; 2 undefined</code>
  <code>=&gt; 1 foo</code></p>
  
  <p>I need the result but like this:
  <code>=&gt; 1 foo</code>
  <code>=&gt; 2 foo</code></p>
  
  <p>Can you help me by writing me a little example? i already read that it might work with <code>.on</code> and <code>.end</code> but i don't understand how !</p>