Merge branch 'fix-stream-report-error' into 'mgx_ops'

stop stream report if CancelledError

See merge request pub/MetaGPT!403
This commit is contained in:
张雷 2024-10-24 01:57:55 +00:00
commit 6e5dfc1ca4

View file

@ -165,9 +165,9 @@ class ResourceReporter(BaseModel):
self._llm_task = asyncio.create_task(self._llm_stream_report(queue))
return self
async def __aexit__(self, *args, **kwargs):
async def __aexit__(self, exc_type, exc_value, exc_tb):
"""Exit the asynchronous streaming callback context."""
if self.enable_llm_stream:
if self.enable_llm_stream and exc_type != asyncio.CancelledError:
await get_llm_stream_queue().put(None)
await self._llm_task
self._llm_task = None