yield from waiter ConnectionResetError

asyncio+aiohttp implemnt multiple request to different domain,patrs of requets raise exception as fllows:
but when testing the single domain,the excetion disappeared.I have met the bug a few days,help!!!



Traceback (most recent call last):
  File "/home/jojo/Documents/boceProject/aiohttp/connector.py", line 822, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 803, in create_connection
    sock, protocol_factory, ssl, server_hostname)
  File "/usr/lib/python3.6/asyncio/base_events.py", line 829, in _create_connection_transport
    yield from waiter
ConnectionResetError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/jojo/Documents/boceProject/test.py", line 57, in <module>
    loop.run_until_complete(main())
  File "/usr/lib/python3.6/asyncio/base_events.py", line 467, in run_until_complete
    return future.result()
  File "/home/jojo/Documents/boceProject/test.py", line 54, in main
    await asyncio.gather(*tasks)
  File "/home/jojo/Documents/boceProject/test.py", line 32, in fetch
    verify_ssl=False) as resp:
  File "/home/jojo/Documents/boceProject/aiohttp/client.py", line 843, in __aenter__
    self._resp = await self._coro
  File "/home/jojo/Documents/boceProject/aiohttp/client.py", line 366, in _request
    timeout=timeout
  File "/home/jojo/Documents/boceProject/aiohttp/connector.py", line 445, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/home/jojo/Documents/boceProject/aiohttp/connector.py", line 754, in _create_connection
    req, traces, timeout)
  File "/home/jojo/Documents/boceProject/aiohttp/connector.py", line 961, in _create_proxy_connection
    req=req)
  File "/home/jojo/Documents/boceProject/aiohttp/connector.py", line 829, in _wrap_create_connection
    raise client_error(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 106.119.181.44:443 ssl:False [None]


my code as fllows: ‘res_connect’ is a redis connecttion


from collections import defaultdict
from config import res_connect
import requests.packages.urllib3.util.ssl_
import aiohttp, asyncio, time, ast, sys, socket
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = 'ALL'

THREAD_NUM = 4286
result = []
SUM = 4000

UPLOADDICT = defaultdict(list)


def get_ip():
    ip = res_connect.rpop('sss')
    if ip:
        ip = ast.literal_eval(ip.decode())
        return ip.get('url')
    return None


async def fetch(client, url):
    while True:
        try:
            async with client.get(url, timeout=5, allow_redirects=False,
                                            verify_ssl=False) as resp:
                status = resp.status
                print(status)
        except TimeoutError as e:
            print(repr(e))
        url = get_ip()
        if url is None:
            break


async def main():
    conn = aiohttp.TCPConnector(limit=1000)
    async with aiohttp.ClientSession(connector=conn) as client:
        tasks = []
        for _ in range(THREAD_NUM):
            ip = get_ip()
            if ip:
                tasks.append(fetch(client, ip))
            else:
                break
        if tasks:
            await asyncio.gather(*tasks)

loop = asyncio.get_event_loop()
loop.run_until_complete(main())




Hi @Qwcscy, this appears to be a request for assistance and with a separate project (aiohttp). I would suggest either filing an issue with them or on Stackoverflow since this issue tracker is reserved for defect reports in Requests. Thanks!

ok,so how can I solve this problem?