title: Proper way to clear an asyncio queue in python3?
body: <p>Errors in my producer/consumer coroutines may leave items and unfinished tasks in the asyncio queue. If an error is encountered, I want to simply stop the loop, cancel the pending tasks and clear the queue. While I can finish the first two things, I cannot find an easy way to clear the queue. After reading <a href="https://stackoverflow.com/a/18873213/2923419">this answer</a>, I come up with three methods:</p>
  
  <pre><code>import asyncio
  
  q=asyncio.Queue()
  for i in range(5):
      q.put_nowait(i)
  q.get_nowait()
  
  loop=asyncio.get_event_loop()
  
  #this will raise an error if q cannot join
  loop.run_until_complete(asyncio.wait_for(q.join(),1))
  
  #method 1
  q._queue.clear()
  q._finished.set()
  q._unfinished_tasks = 0
  
  #method 2
  for _ in range(q.qsize()):
      q.get_nowait()
  for _ in range(q._unfinished_tasks):
      q.task_done()
  
  #method 3
  del q
  q=asyncio.Queue()
  </code></pre>
  
  <p>So which one is better?</p>