title: Evaluating data passed through multiprocess pipe
body: <p>I noticed data received through a multiprocess pipe can not be evaulated directly. In the example below, the code gets stuck in the child process.</p>
  <pre><code>import multiprocessing as mp
  
  def child(conn):
      while True:
          if conn.recv()==1:
              conn.send(1)
  
          if conn.recv()==2:
              conn.send(2)
  
      conn.close()
  
  def main():
  
      parent_conn, child_conn = mp.Pipe()
      p = mp.Process(target=child, args=(child_conn,))
      p.start()
  
      while True:
          parent_conn.send(1)
          print(parent_conn.recv())
  
      p.join()
  
  if __name__ == '__main__':
      main()
  </code></pre>
  <p>But if I assign a variable to conn.recv() in the child process, as shown below. Then everything works.</p>
  <pre><code>def child(conn):
      while True:
  
          x = conn.recv()
          
          if x==1:
              conn.send(1)
  
          if x==2:
              conn.send(2)
  
      conn.close()
  </code></pre>
  <p>I assume this is because the parent and child processes are running concurrently, so the data being passed should only be evaluated as they are received. Is this the the cause?</p>
  <p>I am running Python 3.7 on Windows 10.</p>