MCPcopy Create free account
hub / github.com/CommonstackAI/UncommonRoute / _gen

Function _gen

uncommon_route/proxy.py:3771–3784  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3769 queue = await bus.subscribe()
3770
3771 async def _gen() -> AsyncGenerator[bytes, None]:
3772 yield b": connected\n\n"
3773 try:
3774 while True:
3775 if await request.is_disconnected():
3776 break
3777 try:
3778 event = await asyncio.wait_for(queue.get(), timeout=15.0)
3779 payload = json.dumps(event, default=str)
3780 yield f"data: {payload}\n\n".encode("utf-8")
3781 except asyncio.TimeoutError:
3782 yield b": keepalive\n\n"
3783 finally:
3784 await bus.unsubscribe(queue)
3785
3786 return StreamingResponse(
3787 _gen(),

Callers 1

handle_events_streamFunction · 0.85

Calls 2

unsubscribeMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected