title: Python threads to accumulate items to a collection
body: <p>I have threads to add items to let's say a global success list.</p>
  
  <p>I know that thread communications should be done via <code>Queue</code>s, but when reading the Queue <a href="https://docs.python.org/2/library/queue.html" rel="nofollow noreferrer">documentation</a>, there is no function to get exact count of the queue length. </p>
  
  <blockquote>
    <p>Queue.qsize() Return the approximate size of the queue. Note, qsize()</p>
    
    <blockquote>
      <p>0 doesn’t guarantee that a subsequent get() will not block, nor will qsize() &lt; maxsize guarantee that put() will not block.</p>
    </blockquote>
  </blockquote>
  
  <p>I have also tried <code>len(queue)</code> but it doesn't work:</p>
  
  <pre><code>&gt;&gt;&gt; import Queue
  &gt;&gt;&gt; q = Queue.Queue()
  &gt;&gt;&gt; q.put(1)
  &gt;&gt;&gt; q.put(2)
  &gt;&gt;&gt; len(q)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  AttributeError: Queue instance has no attribute '__len__'
  </code></pre>
  
  <p>I have also read about using <code>List</code> but I <a href="https://stackoverflow.com/questions/6319207/are-lists-thread-safe">don't have definite answer</a> if the data will be corrupted or not.</p>
  
  <p>My only option I can think of right now is to run <code>queue.get()</code> until <code>queue</code> is empty to convert to a list. Is there a better choice?</p>