mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-09-04 10:11:46 +03:00
fix(sdk): preserve queued events on stream close
Signed-off-by: Lanre Shittu <136805224+Shizoqua@users.noreply.github.com>
This commit is contained in:
+1
-1
@@ -302,7 +302,7 @@ class Nanobot:
|
||||
))
|
||||
raise
|
||||
finally:
|
||||
emitter.close()
|
||||
await emitter.close()
|
||||
|
||||
task = asyncio.create_task(_run())
|
||||
return RunStream(task, queue)
|
||||
|
||||
@@ -158,15 +158,11 @@ class SDKStreamEmitter:
|
||||
resuming=resuming,
|
||||
))
|
||||
|
||||
def close(self) -> None:
|
||||
async def close(self) -> None:
|
||||
if self._closed:
|
||||
return
|
||||
self._closed = True
|
||||
if self._queue.full():
|
||||
with suppress(asyncio.QueueEmpty):
|
||||
self._queue.get_nowait()
|
||||
with suppress(asyncio.QueueFull):
|
||||
self._queue.put_nowait(_STREAM_SENTINEL)
|
||||
await self._queue.put(_STREAM_SENTINEL)
|
||||
|
||||
|
||||
class SDKStreamingHook(AgentHook):
|
||||
|
||||
Reference in New Issue
Block a user