title: How to read stdin buffer in advance before an EOF in python3?
body: <p>In my python code I wrote the following function to receive self-defined binary package from stdin.</p>
  
  <pre><code>def recvPkg():
       ## The first 4 bytes stands for the remaining package length
      Len = int.from_bytes(sys.stdin.buffer.read(4), byteorder='big', signed=True)
       ## Then read the remaining package
      data = json.loads(str(sys.stdin.buffer.read(Len), 'utf-8'))
       ## do something...
  
  while True:
      recvPkg()
  </code></pre>
  
  <p>Then, in another Node.js program I spawn this python program as a child process, and send bytes to it.</p>
  
  <pre><code>childProcess = require('child_process').spawn('./python_code.py');
  childProcess.stdin.write(someBinaryPackage)
  </code></pre>
  
  <p>I expect the child process to read from its stdin buffer once a package is received and give the output. But it doesn't work, and I think the reason is that the child process won't begin to read unless its stdin buffer receive a signal, like an EOF. As a proof, if I close childProcess's stdin after stdin.write, the python code will work and receive all the buffered packages at once. This is not the way I want because I need childProcess's stdin to be open. So is there any other way for node.js to send a signal to childProcess to inform of reading from stdin buffer?</p>
  
  <p>(sorry for poor english.</p>