mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-01 07:13:00 +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
|
yield item
|
||||||
finally:
|
finally:
|
||||||
if not cancel_event.is_set():
|
if not cancel_event.is_set():
|
||||||
await task
|
try:
|
||||||
|
await task
|
||||||
|
except (asyncio.CancelledError, Exception): # noqa: S110
|
||||||
|
pass
|
||||||
else:
|
else:
|
||||||
if not task.done():
|
if not task.done():
|
||||||
task.cancel()
|
task.cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user