title: I don't understand An asyncio.Future, a coroutine or an awaitable is required
body: <p>I have issues understanding why this code doesn't work (text explanation of the problem below):</p>
  <pre class="lang-py prettyprint-override"><code>import asyncio
  from random import randrange
  
  def main_function():
      n = randrange(2)
      if n:
          return 1
      else:
          return None
  
  def backup_function():
      return 1
  
  async def run():
      jobs1 = [main_function() for _ in range(0, 5)]
      jobs2 = [backup_function() for _ in range(0, 5)]
  
      _res = await asyncio.gather(*jobs1)
      if len(_res) &lt; 5:
          _res = await asyncio.gather(*jobs2)
  
  if __name__ == '__main__':
      loop = asyncio.new_event_loop()
      loop.run_until_complete(run())
  </code></pre>
  <p>Ok, let's say I have an async function <code>run</code> where I have a list of jobs <code>jobs1</code> I want to get done by calling <code>asyncio.gather</code>. These jobs are simulated in my example by the function <code>main_function</code>, because, in short, the real function we are talking about here returns 'something' or None, whether it internally 'fails' or not, simulated with <code>return 1</code> or <code>return None</code>. <code>asyncio.gather</code> returns a list with the results of the executed jobs, so my understanding. I thought, that <code>await</code> now waits for all jobs to finish, so, <code>_res</code>could be an empty list or filled with a maximum of five 1s, depending on <code>randrange(2)</code> in this case, of course.</p>
  <p>I now need to check, if all of the executions of my <code>jobs1</code> returned a 1 or if there may have been one execution, which returned <code>None</code>, so I wanted to check that with <code>if len(_res) &lt; 5</code>, and in this case, execute another <code>asyncio.gather</code> with another <code>backup_function</code>, but this leads to an error:</p>
  <pre><code>Traceback (most recent call last):
    File &quot;/home/cptsnuggles/run.py&quot;, line 290, in &lt;module&gt;
      loop.run_until_complete(run())
    File &quot;/usr/lib/python3.9/asyncio/base_events.py&quot;, line 642, in run_until_complete
      return future.result()
    File &quot;/home/cptsnuggles/run.py&quot;, line 282, in run
      _res = await asyncio.gather(*jobs1, return_exceptions=True)
    File &quot;/usr/lib/python3.9/asyncio/tasks.py&quot;, line 827, in gather
      fut = ensure_future(arg, loop=loop)
    File &quot;/usr/lib/python3.9/asyncio/tasks.py&quot;, line 680, in ensure_future
      raise TypeError('An asyncio.Future, a coroutine or an awaitable is '
  TypeError: An asyncio.Future, a coroutine or an awaitable is required
  
  Process finished with exit code 1
  </code></pre>
  <p>I think, I'm missing something in my fundamental understanding here but I can't figure it out alone. Thank you for your replies!</p>