49b9bb6724
Deploy Docs / deploy-docs (push) Failing after 1s
Conformance Tests / client-conformance (push) Failing after 3s
Conformance Tests / server-conformance (push) Failing after 1s
GitHub Actions Security Analysis / zizmor (push) Failing after 1s
CI / checks (push) Failing after 59m20s
CI / all-green (push) Waiting to run
21 lines
694 B
Python
21 lines
694 B
Python
import anyio
|
|
|
|
from mcp import Client
|
|
from mcp.client.subscriptions import SubscriptionLost
|
|
|
|
from .tutorial003 import read_board
|
|
|
|
|
|
async def keep_following(client: Client) -> None:
|
|
while True:
|
|
try:
|
|
async with client.listen(resource_subscriptions=["board://sprint"]) as sub:
|
|
print(await read_board(client)) # refetch: no replay across streams
|
|
async for _event in sub:
|
|
print(await read_board(client))
|
|
except SubscriptionLost:
|
|
pass
|
|
# Either ending means the stream is gone. Back off before re-listening:
|
|
# a graceful close may be the server shedding load.
|
|
await anyio.sleep(1)
|