title: aiohttp - Splitting task while getting large number of HTML pages - RuntimeError: cannot reuse already awaited coroutine
body: <p>I have list of URL links which I get and save to HTML files with following code:</p>
  <pre><code>    tasksURL = []
      async with aiohttp.ClientSession() as session:
          for url in listOfURLs:
              tasksURL.append(self.fetch(session, url))
          allHTMLs = await asyncio.gather(*tasksURL)
      i = 0
      for html in allHTMLs:
          i += 1
          with open(&quot;myPath.html&quot;, mode='w', encoding='UTF-8', errors='strict', buffering=1) as f:
              f.write(html)
  </code></pre>
  <p>Since URL list can be quite large (up to 60 000) I need to chunk this tasks.</p>
  <p>I tried following solution. I've defined function that will chop list in smaller chunks with this function:</p>
  <pre><code>def chunkList(self, listOfURLs, n):
      &quot;&quot;&quot;Yield successive n-sized chunks from lst.&quot;&quot;&quot;
      for i in range(0, len(lst), n):
          yield lst[i:i + n]
  </code></pre>
  <p>And than use this function to run each chunked piece of <code>listOfURLs</code> like this:</p>
  <pre><code>tasksURL = []
  chunkedListOfURLs = self.chunkList(listOfURLs, 5)
  for URLList in chunkedListOfURLs:
      async with aiohttp.ClientSession() as session:
          for url in URLList:
              tasksURL.append(self.fetch(session, url))
          allHTMLs = await asyncio.gather(*tasksURL)
      for html in allHTMLs:
          with open(&quot;myPath.html&quot;, mode='w', encoding='UTF-8', errors='strict', buffering=1) as f:
              f.write(html)
  </code></pre>
  <p>I'm getting error:</p>
  <blockquote>
  <p>RuntimeError: cannot reuse already awaited coroutine</p>
  </blockquote>
  <p>I understand problem but haven't found way around it.</p>