title: Why am I getting a "Task was destroyed but it is pending" error in Python asyncio?
body: <p>I use <code>asyncio</code> and beautiful <code>aiohttp</code>. The main idea is that I make request to server (it returns links) and then I want to download files from all links in <strong>parallel</strong> (something like in an <a href="https://docs.python.org/3/library/asyncio-task.html#example-parallel-execution-of-tasks">example</a>).</p>
  
  <p>Code:</p>
  
  <pre><code>import aiohttp
  import asyncio
  
  @asyncio.coroutine
  def downloader(file):
      print('Download', file['title'])
      yield from asyncio.sleep(1.0) # some actions to download
      print('OK', file['title'])
  
  
  def run():
      r = yield from aiohttp.request('get', 'my_url.com', True))
      raw = yield from r.json()
      tasks = []
      for file in raw['files']:
          tasks.append(asyncio.async(downloader(file)))
          asyncio.wait(tasks)
  
  if __name__ == '__main__':
      loop = asyncio.get_event_loop()
      loop.run_until_complete(run())
  </code></pre>
  
  <p>But, when I try to run it, I have many "Download ..." outputs and</p>
  
  <pre><code>Task was destroyed but it is pending!
  </code></pre>
  
  <p>And nothing about 'OK + filename'.</p>
  
  <p>How can I fix that? </p>