Handle broken resource error gracefully

# Conflicts:
#	src/exo/master/api.py
This commit is contained in:
Ryuichi Leo Takashige
2026-01-16 18:32:07 +00:00
parent b5bd0ffc98
commit 313b24fe04
+10 -7
View File
@@ -654,14 +654,17 @@ class API:
for idx, event in self.event_buffer.drain_indexed():
self._event_log.append(event)
self.state = apply(self.state, IndexedEvent(event=event, idx=idx))
if isinstance(event, ChunkGenerated):
if (
isinstance(event, ChunkGenerated)
and event.command_id in self._chat_completion_queues
):
assert isinstance(event.chunk, TokenChunk)
queue = self._chat_completion_queues.get(event.command_id)
if queue is not None:
try:
await queue.send(event.chunk)
except BrokenResourceError:
self._chat_completion_queues.pop(event.command_id, None)
try:
await self._chat_completion_queues[event.command_id].send(
event.chunk
)
except BrokenResourceError:
del self._chat_completion_queues[event.command_id]
async def _pause_on_new_election(self):
with self.election_receiver as ems: