title: RuntimeError: Event loop is closed 'Launcher.killChrome' was never awaited, how to fix?
body: <p>When i run script it spawn huge amount of chromium and on the end not kill it.</p>
  <p>Traceback</p>
  <pre><code>Error in atexit._run_exitfuncs:
  Traceback (most recent call last):
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\site-packages\pyppeteer\launcher.py&quot;, line 151, in _close_process
      self._loop.run_until_complete(self.killChrome())
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 617, in run_until_complete
      self._check_closed()
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 510, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed
  sys:1: RuntimeWarning: coroutine 'Launcher.killChrome' was never awaited
  RuntimeWarning: Enable tracemalloc to get the object allocation traceback
  Error in atexit._run_exitfuncs:
  Traceback (most recent call last):
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\site-packages\pyppeteer\launcher.py&quot;, line 151, in _close_process
      self._loop.run_until_complete(self.killChrome())
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 617, in run_until_complete
      self._check_closed()
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 510, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed
  Error in atexit._run_exitfuncs:
  Traceback (most recent call last):
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\site-packages\pyppeteer\launcher.py&quot;, line 151, in _close_process
      self._loop.run_until_complete(self.killChrome())
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 617, in run_until_complete
      self._check_closed()
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 510, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed
  Error in atexit._run_exitfuncs:
  Traceback (most recent call last):
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\site-packages\pyppeteer\launcher.py&quot;, line 151, in _close_process
      self._loop.run_until_complete(self.killChrome())
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 617, in run_until_complete
      self._check_closed()
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 510, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed
  Error in atexit._run_exitfuncs:
  Traceback (most recent call last):
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\site-packages\pyppeteer\launcher.py&quot;, line 151, in _close_process
      self._loop.run_until_complete(self.killChrome())
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 617, in run_until_complete
      self._check_closed()
    File &quot;C:\Users\PANDEMIC\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py&quot;, line 510, in _check_closed
      raise RuntimeError('Event loop is closed')
  RuntimeError: Event loop is closed
  </code></pre>
  <p>Script</p>
  <pre><code>from requests_html import AsyncHTMLSession
  import asyncio
  import json
  from itertools import chain
  from time import time
  
  async def get_quotes(s, url):
      r = await s.get(url)
      await r.html.arender()
      var_data = r.html.find('script', containing='var data', first=True).text
  
      #this part could be improved, I'm basically isolating the json rendered bit:
      *shit, var_data = var_data.split('var data =')
      var_data, *shit = var_data.split('; for (var i in data)')
  
      data = json.loads(var_data)
      quotes = [post['text'] for post in data]
      return quotes
  
  async def main(max_pages=1):
      s = AsyncHTMLSession()
      tasks = []
      for page in range(1,max_pages+1):
          url = f'http://quotes.toscrape.com/js/page/{page}'
          tasks.append(get_quotes(s,url))
      results = await asyncio.gather(*tasks)
      return list(chain(*(res for res in results)))
  
  
  
  if __name__ == '__main__':
      t0 = time()
      all_quotes = asyncio.run(main(5))
      print(all_quotes)
      print(time() - t0)
  </code></pre>
  <p>It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.It looks like your post is mostly code; please add some more details.</p>