title: What am I doing wrong, in following Python program, as I'm getting global queue empty?
body: <p>I've written this small dummy program which gets a list input e.g.</p>
  
  <pre><code>[1, 2, 3, 4]
  </code></pre>
  
  <p>then output should be</p>
  
  <pre><code>{1:2, 2:4, 3:6, 4:8}
  </code></pre>
  
  <p>When I'm printing the output is</p>
  
  <pre><code>{1: 2}
  {2: 4}
  {3: 6}
  {4: 8}
  True
  True
  True
  True
  {}
  </code></pre>
  
  <p>But somehow the queue is empty.</p>
  
  <pre><code>import Queue
  import math
  import multiprocessing   
  
  out_q = Queue.Queue()
  
  def mp_factorizer(nums):
      global out_q
      def worker(num):
          outdict = {}
          outdict[num] = num * 2
          print outdict
          out_q.put(outdict)
  
      procs = []
      for num in nums:
          p = multiprocessing.Process(target=worker,args=(num,))
          procs.append(p)
          p.start()
  
      resultdict = {}
  
      for p in procs:
          p.join()
  
      for i in range(len(nums)):
          print out_q.empty()
          if not out_q.empty():
              resultdict.update(out_q.get())
  
      # Wait for all worker processes to finish
  
      return resultdict
  
  di = mp_factorizer([1, 2, 3, 4])
  print di
  </code></pre>