title: python asycio RuntimeWarning: coroutine was never awaited
body: <p>I am trying to send many requests to a url (~50) concurrently. </p>
  
  <pre><code>from asyncio import Queue
  
  import yaml
  import asyncio
  
  from aiohttp import ClientSession, TCPConnector
  
  
  async def http_get(url, cookie):
      cookie = cookie.split('; ')
      cookie1 = cookie[0].split('=')
      cookie2 = cookie[1].split('=')
      cookies = {
          cookie1[0]: cookie1[1],
          cookie2[0]: cookie2[1]
      }
  
      async with ClientSession(cookies=cookies) as session:
          async with session.get(url, ssl=False) as response:
              return await response.json()
  
  
  class FetchUtil:
      def __init__(self):
          self.config = yaml.safe_load(open('../config.yaml'))
  
      def fetch(self):
          asyncio.run(self.extract_objects())
  
      async def http_get_objects(self, object_type, limit, offset):
          path = '/path' + \
                 '?query=&amp;filter=%s&amp;limit=%s&amp;offset=%s' % (
                     object_type,
                     limit,
                     offset)
          return await self.http_get_domain(path)
  
      async def http_get_objects_limit(self, object_type, offset):
          result = await self.http_get_objects(
              object_type,
              self.config['object_limit'],
              offset
          )
          return result['result']
  
      async def http_get_domain(self, path):
          return await http_get(
              f'https://{self.config["domain"]}{path}',
              self.config['cookie']
          )
  
      async def call_objects(self, object_type, offset):
          result = await self.http_get_objects_limit(
              object_type,
              offset
          )
          return result
  
      async def extract_objects(self):
          calls = []
          object_count = (await self.http_get_objects(
                  'PV', '1', '0'))['result']['count']
          for i in range(0, object_count, self.config['object_limit']):
              calls.append(self.call_objects('PV', str(i)))
  
          queue = Queue()
          for i in range(0, len(calls), self.config['call_limit']):
              results = await asyncio.gather(*calls[i:self.config['call_limit']])
              await queue.put(results)
  </code></pre>
  
  <p>After running this code using fetch as the entry point i get the following error message:    </p>
  
  <pre><code>/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/asyncio/events.py:88: RuntimeWarning: coroutine 'FetchUtil.call_objects' was never awaited
        self._context.run(self._callback, *self._args)
      RuntimeWarning: Enable tracemalloc to get the object allocation traceback
  </code></pre>
  
  <p>The program that stops executing after <code>asyncio.gather</code> returns for the first time. I am having trouble understanding this message since I thought that I diligently made sure all functions were async tasks. The only function i didn't <code>await</code> was <code>call_objects</code> since i wanted it to run concurrently.</p>
  
  <p><a href="https://xinhuang.github.io/posts/2017-07-31-common-mistakes-using-python3-asyncio.html#org630d301" rel="nofollow noreferrer">https://xinhuang.github.io/posts/2017-07-31-common-mistakes-using-python3-asyncio.html#org630d301</a></p>
  
  <p>in this article gives the following explanation:</p>
  
  <blockquote>
    <p>This runtime warning can happen in many scenarios, but the cause are
    same: A coroutine object is created by the invocation of an async
    function, but is never inserted into an EventLoop.</p>
  </blockquote>
  
  <p>I believed that was what i was doing when i called the async tasks with asyncio.gather. </p>
  
  <p>I should note that when i put a <code>print('url')</code> inside http_get it outputs the first 50 urls like i want, the problem seems to occur when asyncio.gather returns for the first time.</p>