Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 6 additions & 2 deletions src/mcp/shared/jsonrpc_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,14 @@ def _spawn(
message; `Context.run` makes the spawned handler inherit that context.
"""
assert self._tg is not None

async def run() -> None:
await fn(*args)

if sender_ctx is not None:
sender_ctx.run(self._tg.start_soon, fn, *args)
sender_ctx.run(self._tg.start_soon, run)
else:
self._tg.start_soon(fn, *args)
self._tg.start_soon(run)

def _fan_out_closed(self) -> None:
"""Wake every pending `send_raw_request` waiter with `CONNECTION_CLOSED`.
Expand Down
5 changes: 4 additions & 1 deletion tests/client/test_stdio.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ async def die_late() -> None:
process.exit(0)

# The grace wait starts when stdin closes; anchor the death there.
process.on_stdin_close = lambda: tg.start_soon(die_late)
def schedule_death() -> None:
tg.start_soon(die_late)

process.on_stdin_close = schedule_death
# no branch: the tracer drops this nested async-with's arcs under
# trio's MockClock even though the body runs.
async with stdio_client(FAKE_PARAMS): # pragma: no branch
Expand Down
7 changes: 3 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading