Skip to content

Commit b166c29

Browse files
committed
suppress cancel scope error
1 parent 6158742 commit b166c29

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

pydantic_ai_slim/pydantic_ai/_utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,10 @@ def sync_async_iterator(async_iter: AsyncIterator[T]) -> Iterator[T]:
239239
while True:
240240
try:
241241
yield loop.run_until_complete(anext(async_iter))
242+
except RuntimeError as e:
243+
if str(e) == 'Attempted to exit cancel scope in a different task than it was entered in':
244+
break
245+
raise
242246
except StopAsyncIteration:
243247
break
244248

0 commit comments

Comments
 (0)