MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / respond

Function respond

tests/test_open_telemetry.py:657–664  ·  view source on GitHub ↗
(reader: asyncio.StreamReader, writer: asyncio.StreamWriter)

Source from the content-addressed store, hash-verified

655 """Serves the `stream_events` to each request on a local port, and gives the base URL."""
656
657 async def respond(reader: asyncio.StreamReader, writer: asyncio.StreamWriter) -> None:
658 await reader.readuntil(b"\r\n\r\n")
659 body = sse(stream_events())
660 writer.write(b"HTTP/1.1 200 OK\r\ncontent-type: text/event-stream\r\ntransfer-encoding: chunked\r\n\r\n")
661 writer.write(b"%x\r\n%b\r\n0\r\n\r\n" % (len(body), body))
662 await writer.drain()
663 await reader.read()
664 writer.close()
665
666 server = await asyncio.start_server(respond, "127.0.0.1", 0)
667 async with server:

Callers

nothing calls this directly

Calls 5

stream_eventsFunction · 0.85
sseFunction · 0.70
writeMethod · 0.45
readMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected