Update tcp.py

This commit is contained in:
rick 2025-08-11 13:10:45 +07:00 committed by GitHub
parent cb38d6a02b
commit 8ba3e4bb96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -91,10 +91,8 @@ class TCP:
)
sock.settimeout(TCP.TIMEOUT)
await self.loop.sock_connect(
sock=sock,
address=destination
)
# fix: Use run_in_executor for socks.socksocket
await self.loop.run_in_executor(None, sock.connect, destination)
sock.setblocking(False)
@ -123,7 +121,7 @@ class TCP:
async def connect(self, address: Tuple[str, int]) -> None:
try:
await asyncio.wait_for(self._connect(address), TCP.TIMEOUT)
except asyncio.TimeoutError: # Re-raise as TimeoutError. asyncio.TimeoutError is deprecated in 3.11
except asyncio.TimeoutError: # re raise as TimeoutError. asyncio.TimeoutError is deprecated in 3.11
raise TimeoutError("Connection timed out")
async def close(self) -> None: