title: Delete/destroy finished futures asyncio Python
body: <p>I have an Python script which uses asyncio to make over a million requests. I first ran into memory issues and then discovered semaphores, I have since implemented a semaphore successfully to limit the number of concurrent task as well as tasks in the queue at one time. </p>
  
  <p>My program loads a list of requests like this:</p>
  
  <pre><code>        with open(wordlist) as words:
              w = words.read().splitlines()
  </code></pre>
  
  <p>Then that list gets passed to the following function for processing and the actual work gets done.</p>
  
  <pre><code>async def _process_dns_wordlist(self, wordlist, domain):
      """Takes a list of words and adds them to the task list as space is available"""
      for word in wordlist:
          # Wait on the semaphore before adding more tasks
          await self.sem.acquire()
          host = '{}.{}'.format(word, domain)
          task = asyncio.ensure_future(self._dns_lookup(host))
          task.add_done_callback(functools.partial(self._dns_result_callback, host))
          self.tasks.append(task)
      await asyncio.gather(*self.tasks, return_exceptions=True)
  </code></pre>
  
  <p>Before I implemented the semaphore the program would just crash, running out of memory when I was queueing up all the tasks, now it runs a while and then crashes because it runs out of memory about 1/2 way through the requests. </p>
  
  <p>I assume that this is because after the future is processed by my callback it sits there in memory wasting space. My problem is I cannot figure out what to use to delete the processed future once I'm done with it. I've read the asyncio docs and I don't see a destroy/delete method. Am I missing something really obvious? </p>
  
  <p>Thanks for your help! </p>