title: python multiprocessing TypeError: 'int' object is not iterable
body: <p>The following code errors out once in a while. It works fine if I start just one process. But I keep increasing the number of processes to, may be 11 and it starts throwing an error.</p>
  
  <pre><code>try:
      num_workers = int(sys.argv[1])
  except:
      num_workers = 1
  
  someval = 10
  def do_work(in_queue,x):
      i = 0
      while True:
          item = in_queue.get()
          line_no, line = item
  
          # exit signal
          if line == None:
              if i &gt; 0 :
                  work.put(i,)
              # work.put(i)
              return
          else:
              print "value from work " + line.rstrip('\n')
              i = i + 1
  
  if __name__ == "__main__":
  
      manager = Manager()
      work = manager.Queue(num_workers)
      someval = 20
      print " Number of workers is " + str(num_workers)
      pool = []
      for i in xrange(num_workers):
          p = Process(target=do_work, args=(work,someval))
          p.start()
          pool.append(p)
      with open("/home/jay/scripts/a.txt") as f:
           iters = itertools.chain(f, (None,)*num_workers)
           for num_and_line in enumerate(iters):
                  work.put(num_and_line)
  
      x = 0
      for p in pool:
          p.join()
  </code></pre>
  
  <p>The file /home/jay/scripts/a.txt has 10 lines.</p>
  
  <p>If I do </p>
  
  <pre><code> ./x.py 7
       Number of workers is 7
      value from work 1
      value from work 2
      value from work 3
      value from work 4
      value from work 5
      value from work 6
      value from work 7
      value from work 8
      value from work 9
      value from work 10
       x is 0
       all done 
  
  ./x.py 11
   Number of workers is 11
  value from work 1
  value from work 2
  value from work 3
  value from work 4
  value from work 5
  value from work 6
  value from work 7
  value from work 8
  value from work 9
  value from work 10
  Process Process-11:
  Traceback (most recent call last):
    File "/usr/lib64/python2.7/multiprocessing/process.py", line 258, in _bootstrap
      self.run()
    File "/usr/lib64/python2.7/multiprocessing/process.py", line 114, in run
      self._target(*self._args, **self._kwargs)
    File "./x.py", line 18, in do_work
      line_no, line = item
  TypeError: 'int' object is not iterable
   x is 0
   all done 
  </code></pre>