Skip to content

Commit 514e603

Browse files
RobLe3claude
andcommitted
[python] #359 relay connect timeout (10s) + v0.7.7
Why: RelayWorkerClient connected without an app-level timeout, so a TCP-reachable-but-not-accepting relay could block ~75s+ on the OS default. asyncio.wait_for(open_connection, 10s) fails fast; run() reconnects. Bundles the iter-1504 mypy annotations (already on main). 213 tests pass; ruff clean. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 401e8d8 commit 514e603

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "iicp-client"
7-
version = "0.7.5"
7+
version = "0.7.7"
88
description = "Official Python client SDK for the IICP protocol"
99
readme = "README.md"
1010
license = {text = "Apache-2.0"}

src/iicp_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
TaskResponse,
5050
)
5151

52-
__version__ = "0.7.5"
52+
__version__ = "0.7.7"
5353
__all__ = [
5454
"IicpClient",
5555
"IicpError",

src/iicp_client/relay_worker_client.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
_HEADER_STRUCT = struct.Struct("!4sBBBBI")
4444
_PING_INTERVAL_S = 30.0
4545
_MAX_RECONNECT_DELAY_S = 60.0
46+
# #359 — explicit connect timeout so a TCP-reachable-but-not-accepting relay
47+
# (firewall RST after delay, port scan) fails fast instead of blocking on the
48+
# OS default (~75s+). The run() loop catches the TimeoutError and reconnects.
49+
_CONNECT_TIMEOUT_S = 10.0
4650

4751
# Frame type constants (mirrors MsgType in iicp_tcp.py)
4852
_MT_INIT = 0x01
@@ -161,7 +165,10 @@ async def run(self) -> None:
161165
delay = min(delay * 2, _MAX_RECONNECT_DELAY_S)
162166

163167
async def _session(self) -> None:
164-
reader, writer = await asyncio.open_connection(self._relay_host, self._relay_port)
168+
reader, writer = await asyncio.wait_for(
169+
asyncio.open_connection(self._relay_host, self._relay_port),
170+
timeout=_CONNECT_TIMEOUT_S,
171+
)
165172
logger.debug(
166173
"Relay worker %s: connected to %s:%d",
167174
self._worker_id, self._relay_host, self._relay_port,

0 commit comments

Comments
 (0)