Skip to content

Commit 086b2dd

Browse files
committed
Adapt task spawning to AnyIO 4.14 typing
1 parent a62369f commit 086b2dd

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

‎src/mcp/shared/jsonrpc_dispatcher.py‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,14 @@ def _spawn(
680680
message; `Context.run` makes the spawned handler inherit that context.
681681
"""
682682
assert self._tg is not None
683+
684+
async def run() -> None:
685+
await fn(*args)
686+
683687
if sender_ctx is not None:
684-
sender_ctx.run(self._tg.start_soon, fn, *args)
688+
sender_ctx.run(self._tg.start_soon, run)
685689
else:
686-
self._tg.start_soon(fn, *args)
690+
self._tg.start_soon(run)
687691

688692
def _fan_out_closed(self) -> None:
689693
"""Wake every pending `send_raw_request` waiter with `CONNECTION_CLOSED`.

‎tests/client/test_stdio.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,10 @@ async def die_late() -> None:
444444
process.exit(0)
445445

446446
# The grace wait starts when stdin closes; anchor the death there.
447-
process.on_stdin_close = lambda: tg.start_soon(die_late)
447+
def schedule_death() -> None:
448+
tg.start_soon(die_late)
449+
450+
process.on_stdin_close = schedule_death
448451
# no branch: the tracer drops this nested async-with's arcs under
449452
# trio's MockClock even though the body runs.
450453
async with stdio_client(FAKE_PARAMS): # pragma: no branch

0 commit comments

Comments
 (0)