title: How can I get the return value of a process in Python?
body: <p>I have some code that does the following:</p>
  
  <ul>
  <li>Creates a process (process is solvePuzzle(filename))</li>
  <li>Runs the process</li>
  <li>If the process finishes within timeLimit, do something</li>
  <li>If the process times out, do something else</li>
  </ul>
  
  <p>My issue is with the third task; I want to be able to get the return value of the function that was processed. Here is my code (I made up the statement p.returnValue() as this is what I'm trying to do):</p>
  
  <pre><code>    #Start process
      p = multiprocessing.Process(target=globals()['solvePuzzle'], args=(filename,))        
      p.start()
  
      #Wait for timeLimit seconds or until process finishes
      p.join(timeLimit)
  
      #If thread is still active
      if p.is_alive():
          print "Puzzle timed out after " + str(timeLimit) + " seconds!"
  
          # Terminate
          p.terminate()
          p.join()
      else:
          print "Solution = " + str(p.returnValue())
  </code></pre>