title: Understanding os.fork and Queue.Queue
body: <p>I wanted to implement a simple python program using parallel execution.  It's I/O bound, so I figured threads would be appropriate (as opposed to processes).  After reading the documentation for Queue and fork, I thought something like the following might work.</p>
  
  <pre><code>q = Queue.Queue()
  
  if os.fork():            # child
      while True:
          print q.get()
  else:                    # parent
      [q.put(x) for x in range(10)]
  </code></pre>
  
  <p>However, the get() call never returns.  I thought it would return once the other thread executes a put() call.  Using the threading module, things behave more like I expected:</p>
  
  <pre><code>q = Queue.Queue()
  
  def consume(q):
      while True:
          print q.get()
  
  worker = threading.Thread (target=consume, args=(q,))
  worker.start()
  
  [q.put(x) for x in range(10)]
  </code></pre>
  
  <p>I just don't understand why the fork approach doesn't do the same thing.  What am I missing?</p>