Skip to content

Commit 157987d

Browse files
fix(python): remove 30s default timeout from JsonRpcClient.request()
The Python SDK's JsonRpcClient.request() had a hardcoded 30s default timeout via asyncio.wait_for(), unlike the other three SDK languages (Go, Node/TS, .NET) which all wait indefinitely for the server to respond. Change the default from timeout=30.0 to timeout=None so that requests wait indefinitely by default, matching the behavior of the other SDKs. Callers can still pass an explicit timeout when needed. Fixes #539 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent f9144f1 commit 157987d

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

python/copilot/jsonrpc.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,22 +104,23 @@ async def stop(self):
104104
self._stderr_thread.join(timeout=1.0)
105105

106106
async def request(
107-
self, method: str, params: Optional[dict] = None, timeout: float = 30.0
107+
self, method: str, params: Optional[dict] = None, timeout: Optional[float] = None
108108
) -> Any:
109109
"""
110110
Send a JSON-RPC request and wait for response
111111
112112
Args:
113113
method: Method name
114114
params: Optional parameters
115-
timeout: Request timeout in seconds (default 30s)
115+
timeout: Optional request timeout in seconds. If None (default),
116+
waits indefinitely for the server to respond.
116117
117118
Returns:
118119
The result from the response
119120
120121
Raises:
121122
JsonRpcError: If server returns an error
122-
asyncio.TimeoutError: If request times out
123+
asyncio.TimeoutError: If request times out (only when timeout is set)
123124
"""
124125
request_id = str(uuid.uuid4())
125126

@@ -141,7 +142,9 @@ async def request(
141142
await self._send_message(message)
142143

143144
try:
144-
return await asyncio.wait_for(future, timeout=timeout)
145+
if timeout is not None:
146+
return await asyncio.wait_for(future, timeout=timeout)
147+
return await future
145148
finally:
146149
with self._pending_lock:
147150
self.pending_requests.pop(request_id, None)

0 commit comments

Comments
 (0)