mirror of
https://github.com/Mayuri-Chan/pyrofork.git
synced 2026-01-07 15:34:52 +00:00
Update tcp.py
This commit is contained in:
parent
cb38d6a02b
commit
8ba3e4bb96
1 changed files with 3 additions and 5 deletions
|
|
@ -91,10 +91,8 @@ class TCP:
|
||||||
)
|
)
|
||||||
sock.settimeout(TCP.TIMEOUT)
|
sock.settimeout(TCP.TIMEOUT)
|
||||||
|
|
||||||
await self.loop.sock_connect(
|
# fix: Use run_in_executor for socks.socksocket
|
||||||
sock=sock,
|
await self.loop.run_in_executor(None, sock.connect, destination)
|
||||||
address=destination
|
|
||||||
)
|
|
||||||
|
|
||||||
sock.setblocking(False)
|
sock.setblocking(False)
|
||||||
|
|
||||||
|
|
@ -123,7 +121,7 @@ class TCP:
|
||||||
async def connect(self, address: Tuple[str, int]) -> None:
|
async def connect(self, address: Tuple[str, int]) -> None:
|
||||||
try:
|
try:
|
||||||
await asyncio.wait_for(self._connect(address), TCP.TIMEOUT)
|
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")
|
raise TimeoutError("Connection timed out")
|
||||||
|
|
||||||
async def close(self) -> None:
|
async def close(self) -> None:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue