async def subscribe(request: Request):
topics = request.path_params["topics"]
async def event_publisher(topics: List[str]):
receiver = Receiver(topics)
try:
while True:
try:
async with timeout(WAIT_FOR_NEW_MESSAGE_TIMEOUT):
message = await receiver.get_message()
except TimeoutError:
continue
yield message
except CancelledError as e:
logger.info(f"Disconnected from client (via refresh/close) {request.client}")
raise e
return EventSourceResponse(event_publisher(topics.split(",")), ping=config["SSE_KEEPALIVE"])
Every once in a while I notice that GeneratorExit shows up at this endpoint. Is this an expected behavior? I thought client hang-up is handled by CanceledError. So where does this GeneratorExit come from?
Hi, I have some simple endpoint using sse:
Every once in a while I notice that GeneratorExit shows up at this endpoint. Is this an expected behavior? I thought client hang-up is handled by CanceledError. So where does this GeneratorExit come from?