Заметил что если без uvloop выполнить этот код то все ок
async def main():
async with ClientSession(
json_serialize=ujson.dumps,
timeout=aiohttp.ClientTimeout(total=6),
) as session:
async with session.get(
"https://api.ipify.org?format=json",
proxy="http://proxy",
) as response:
print((await response.json()))
if __name__ == "__main__":
# uvloop.install()
asyncio.run(main(), debug=True)
но если выполнять так
async def main():
async with ClientSession(
json_serialize=ujson.dumps,
timeout=aiohttp.ClientTimeout(total=6),
) as session:
async with session.get(
"https://api.ipify.org?format=json",
proxy="http://proxy",
) as response:
print((await response.json()))
if __name__ == "__main__":
uvloop.install()
asyncio.run(main(), debug=True)
Добавилась строчка
uvloop.install()
То кидает warn
RuntimeWarning: An HTTPS request is being sent through an HTTPS proxy. This support for TLS in TLS is known to be disabled in the stdlib asyncio. This is why you'll probably see an error in the log below.
It is possible to enable it via monkeypatching under Python 3.7 or higher. For more details, see:
* https://bugs.python.org/issue37179
* https://github.com/python/cpython/pull/28073
You can temporarily patch this as follows:
* https://docs.aiohttp.org/en/stable/client_advanced.html#proxy-support
* https://github.com/aio-libs/aiohttp/discussions/6044
_, proto = await self._create_proxy_connection(req, traces, timeout)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Как быть если нужен uvloop?