8000 fix: HTTP timeout correctly passed to httpx by akharlamov · Pull Request #956 · modelcontextprotocol/python-sdk · GitHub
[go: up one dir, main page]

Skip to content

fix: HTTP timeout correctly passed to httpx #956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/mcp/client/sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async def sse_client(
client,
"GET",
url,
timeout=httpx.Timeout(timeout, read=sse_read_timeout),
Copy link
Member
@Kludex Kludex Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is being passed on line 57... 👀

) as event_source:
event_source.response.raise_for_status()
logger.debug("SSE connection established")
Expand Down Expand Up @@ -106,7 +107,7 @@ async def sse_reader(
case _:
logger.warning(f"Unknown SSE event: {sse.event}")
except Exception as exc:
logger.error(f"Error in sse_reader: {exc}")
logger.error(f"Error in sse_reader: {exc.__class__.__name__}", exc_info=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger.error(f"Error in sse_reader: {exc.__class__.__name__}", exc_info=True)
logger.exception("Error in sse_reader")

await read_stream_writer.send(exc)
finally:
await read_stream_writer.aclose()
Expand All @@ -127,7 +128,8 @@ async def post_writer(endpoint_url: str):
response.raise_for_status()
logger.debug("Client message sent successfully: " f"{response.status_code}")
except Exception as exc:
logger.error(f"Error in post_writer: {exc}")
logger.error(f"Error in post_writer: {exc.__class__.__name__}", exc_info=True)
await read_stream_writer.send(exc)
finally:
await write_stream.aclose()

Expand Down
Loading
0