title: Python asyncio queue not updated
body: <p>The following code instantiates an <code>asyncio.Queue</code> object, and tries to populate and consume this queue from two different coroutines, respectively <code>arrival()</code> and <code>server()</code>.</p>
  
  <pre><code>loop = asyncio.get_event_loop()
  q = asyncio.Queue()
  
  async def arrival(q):
      print('ARRIVAL - Queue id:', id(q))
  
      while True:
          await asyncio.sleep(1)
          item = random.choice(['item1', 'item2'..., 'item100'])
          q.put(item)
  
          print('ARRIVAL - added {}, qsize is now {}'.format(item, q.qsize()))
  
  
  async def server(q):
      print('SERVER - Queue id:', id(q))
  
      while True:
          item = await q.get()
          print('SERVER - taking {}, qsize is now {}'.format(item, q.qsize()))
  
          await asyncio.sleep(1.8)
          print('SERVER - finished processing {}'.format(item))
  
  
  tasks = [loop.create_task(arrival(q)), loop.create_task(server(q))]
  loop.run_until_complete(asyncio.gather(*tasks))
  </code></pre>
  
  <p>The principle is the following:</p>
  
  <ul>
  <li>Every 1 second, an item is added to <code>q</code></li>
  <li>Anytime the server is free, it takes the next item in the queue or waits for it</li>
  <li>The server takes 1.8 seconds to process an item</li>
  </ul>
  
  <p>The expected output would be:</p>
  
  <pre><code>SERVER - Queue id: 12345678
  ARRIVAL - Queue id: 12345678
  ARRIVAL - added item1, qsize is now 1
  SERVER - taking item1, qsize is now 0
  ARRIVAL - added item2, qsize is now 1
  SERVER - finished processing item1
  SERVER - taking item2, qsize is now 0
  ARRIVAL - added item3, qsize is now 1
  ARRIVAL - added item4, qsize is now 2
  SERVER - finished processing item2
  SERVER - taking item3, qsize is now 1
  ARRIVAL - added item5, qsize is now 2
  ARRIVAL - added item6, qsize is now 3
  SERVER - finished processing item3
  SERVER - taking item4, qsize is now 2
  </code></pre>
  
  <p>However when I run the above code, the elements in <code>while True</code> loop in <code>server()</code> are never executed, <code>q.qsize()</code> is always 0, and the output is:</p>
  
  <pre><code>SERVER - Queue id: 12345678
  ARRIVAL - Queue id: 12345678
  ARRIVAL - added item1, qsize is now 0
  ARRIVAL - added item2, qsize is now 0
  ARRIVAL - added item3, qsize is now 0
  ARRIVAL - added item4, qsize is now 0
  ARRIVAL - added item5, qsize is now 0
  ...
  </code></pre>
  
  <p>It seems that the <code>q</code> object is never updated by <code>arrival()</code> (<code>q.qsize()</code> is always 0) and hence <code>server()</code> is never aware of the items added by <code>arrival()</code>.</p>