title: OSError: [WinError 995] - [asyncio, aiohttp]
body: <p>This snippet of code is not working on my local machine!
  I try the same snippet on a cloud server, and it's working like a charm!</p>
  <p>I googled it, but I didn't find anything related, I do not know what is wrong!</p>
  <p>Furthermore, I try reinstalling python, reinstalling libs, but the same error happens.
  My local machine specifications:</p>
  <p>Windows: Win11
  Python Version : Python 3.10.5</p>
  <pre class="lang-py prettyprint-override"><code>import asyncio
  import aiohttp
  import time
  
  
  async def get_tasks(session):
      tasks = []
      for page in range(1, 10):
          url = &quot;https://www.google.com/search?q=&quot; + str(page)
          header = {'User-Agent': 'Mozilla/5.0'}
          task = asyncio.create_task(session.get(url, headers=header))
          tasks.append(task)
      results = await asyncio.gather(*tasks)
      return results
  
  
  async def main():
      async with aiohttp.ClientSession() as session:
          responses = await get_tasks(session)
          for response in responses:
              await response.text()
  
  if __name__ == &quot;__main__&quot;:
      start_time = time.time()
      asyncio.run(main())
      print(&quot;--- %s seconds ---&quot; % (time.time() - start_time))
  </code></pre>
  <pre><code>Traceback (most recent call last):
    File &quot;c:\Users\Mohamed Anan\GitHub\Web-Scraping\anan\async.py&quot;, line 25, in &lt;module&gt;
      asyncio.run(main())
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py&quot;, line 44, in run
      return loop.run_until_complete(main)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py&quot;, line 646, in run_until_complete
      return future.result()
    File &quot;c:\Users\Mohamed Anan\GitHub\Web-Scraping\anan\async.py&quot;, line 19, in main
      responses = await get_tasks(session)
    File &quot;c:\Users\Mohamed Anan\GitHub\Web-Scraping\anan\async.py&quot;, line 13, in get_tasks
      results = await asyncio.gather(*tasks)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\client.py&quot;, line 1122, in send
      return self._coro.send(arg)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\client.py&quot;, line 535, in _request
      conn = await self._connector.connect(
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\connector.py&quot;, line 542, in connect
      proto = await self._create_connection(req, traces, timeout)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\connector.py&quot;, line 907, in _create_connection
      _, proto = await self._create_direct_connection(req, traces, timeout)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\connector.py&quot;, line 1175, in _create_direct_connection
      transp, proto = await self._wrap_create_connection(
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\site-packages\aiohttp\connector.py&quot;, line 986, in _wrap_create_connection
      return await self._loop.create_connection(*args, **kwargs)  # type: ignore[return-value]  # noqa
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py&quot;, line 1049, in create_connection
      sock = await self._connect_sock(
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py&quot;, line 960, in _connect_sock
      await self.sock_connect(sock, address)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\proactor_events.py&quot;, line 709, in sock_connect
      return await self._proactor.connect(sock, address)
  RuntimeError: await wasn't used with future
  _OverlappedFuture exception was never retrieved
  future: &lt;_OverlappedFuture finished exception=OSError(22, 'The I/O operation has been aborted because of either a thread exit or an application request', None, 995, None)&gt;
  Traceback (most recent call last):
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py&quot;, line 817, in _poll
      value = callback(transferred, key, ov)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py&quot;, line 604, in finish_connect
      ov.getresult()
  OSError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request
  _OverlappedFuture exception was never retrieved
  future: &lt;_OverlappedFuture finished exception=OSError(22, 'The I/O operation has been aborted because of either a thread exit or an application request', None, 995, None)&gt;
  Traceback (most recent call last):
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py&quot;, line 817, in _poll
      value = callback(transferred, key, ov)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py&quot;, line 604, in finish_connect
      ov.getresult()
  OSError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request
  _OverlappedFuture exception was never retrieved
  future: &lt;_OverlappedFuture finished exception=OSError(22, 'The I/O operation has been aborted because of either a thread exit or an application request', None, 995, None)&gt;
  Traceback (most recent call last):
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py&quot;, line 817, in _poll
      value = callback(transferred, key, ov)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py&quot;, line 604, in finish_connect
      ov.getresult()
  OSError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request
  _OverlappedFuture exception was never retrieved
  future: &lt;_OverlappedFuture finished exception=OSError(22, 'The I/O operation has been aborted because of either a thread exit or an application request', None, 995, None)&gt;
  Traceback (most recent call last):
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py&quot;, line 817, in _poll
      value = callback(transferred, key, ov)
    File &quot;C:\Users\Mohamed Anan\AppData\Local\Programs\Python\Python310\lib\asyncio\windows_events.py&quot;, line 604, in finish_connect
      ov.getresult()
  OSError: [WinError 995] The I/O operation has been aborted because of either a thread exit or an application request
  </code></pre>