title: In Python, how do you get data back from a particular process using multiprocessing?
body: <pre><code>import multiprocessing as mp
  import time
  
  def build(q):
      print 'I build things'
      time.sleep(10)
      #return 42
      q.put(42)
  
  def run(q):
      num = q.get()
      print num
  
      if num == 42:
          print 'I run after build is done'
          return
      else:
          raise Exception("I don't know build..I guess")
  
  def get_number(q):
      q.put(3)
  
  if __name__ == '__main__':
      queue = mp.Queue()
  
      run_p = mp.Process(name='run process', target=run, args=(queue,))
      build_p = mp.Process(name='build process', target=build, args=(queue,))
      s3 = mp.Process(name='s3', target=get_number, args=(queue,))
  
      build_p.start()
      run_p.start()
      s3.start()
  
      print 'waiting on build'
      build_p.join(1) # timeout set to 1 second
      s3.join()
  
      print 'waiting on run'
      run_p.join()
  
      queue.close()
      print 'waiting on queue'
      queue.join_thread()
      print 'done'
  </code></pre>
  
  <p>My goal is to send <code>build</code> and <code>run</code> into different workers, and <code>run</code> has to get result back from <code>build</code> in order to proceed.</p>
  
  <p>The above revised code based on your help will actually return exception, because <code>s3</code> is returned before <code>build</code> has the chance.</p>
  
  <p>The value in the front of the queue is now 3. How can we make sure we get the answer back from <code>build</code> process?</p>
  
  <p>Thanks.</p>