title: How to iterate over a large list without blocking event loop
body: <p>I have a python script with a running asyncio event loop, I want to know how to iterate over a large list without blocking the event loop. Thus keeping the loop running.</p>
  
  <p>I've tried making a custom class with <code>__aiter__</code> and <code>__anext__</code> which did not work, I've also tried making an <code>async function</code> that yields the result but it still blocks.</p>
  
  <p>Currently:</p>
  
  <pre class="lang-py prettyprint-override"><code>for index, item in enumerate(list_with_thousands_of_items):
      # do something
  </code></pre>
  
  <p>The custom class I've tried:</p>
  
  <pre class="lang-py prettyprint-override"><code>class Aiter:
      def __init__(self, iterable):
          self.iter_ = iter(iterable)
  
      async def __aiter__(self):
          return self
  
      async def __anext__(self):
          try:
              object = next(self.iter_)
          except StopIteration:
              raise StopAsyncIteration
          return object
  </code></pre>
  
  <p>But that always results in </p>
  
  <pre><code>TypeError: 'async for' received an object from __aiter__ that does not implement __anext__: coroutine
  </code></pre>
  
  <p>The <code>async function</code> I made which works but still blocks the event loop is:</p>
  
  <pre class="lang-py prettyprint-override"><code>async def async_enumerate(iterable, start:int=0):
      for idx, i in enumerate(iterable, start):
          yield idx, i
  </code></pre>