mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-04-11 13:32:34 +00:00
fix: wrap await task in try/except in async generator finally block
Addresses code quality review comment about bare 'await task' having no visible effect. Now consistently handles CancelledError/Exception in both the normal and cancellation paths of the finally block. Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -335,7 +335,10 @@ async def create_async_chunk_generator(
|
||||
yield item
|
||||
finally:
|
||||
if not cancel_event.is_set():
|
||||
await task
|
||||
try:
|
||||
await task
|
||||
except (asyncio.CancelledError, Exception): # noqa: S110
|
||||
pass
|
||||
else:
|
||||
if not task.done():
|
||||
task.cancel()
|
||||
|
||||
Reference in New Issue
Block a user