From 921b593285cd58092eaf94e6cc0b144b498e091d Mon Sep 17 00:00:00 2001 From: S!R X <111647198+SIR-X@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:21:35 +0330 Subject: [PATCH] Fix connection to proxy Fix the proxy bug. Signed-off-by: wulan17 --- pyrogram/connection/transport/tcp/tcp.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pyrogram/connection/transport/tcp/tcp.py b/pyrogram/connection/transport/tcp/tcp.py index 1848ba35..d948b6d2 100644 --- a/pyrogram/connection/transport/tcp/tcp.py +++ b/pyrogram/connection/transport/tcp/tcp.py @@ -21,6 +21,7 @@ import asyncio import ipaddress import logging import socket +from concurrent.futures import ThreadPoolExecutor from typing import Tuple, Dict, TypedDict, Optional import socks @@ -91,10 +92,8 @@ class TCP: ) sock.settimeout(TCP.TIMEOUT) - await self.loop.sock_connect( - sock=sock, - address=destination - ) + with ThreadPoolExecutor() as executor: + await self.loop.run_in_executor(executor, sock.connect, destination) sock.setblocking(False)