We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6158742 commit e07c9f0Copy full SHA for e07c9f0
pydantic_ai_slim/pydantic_ai/result.py
@@ -732,9 +732,13 @@ def _async_iterator_to_sync(
732
func: Callable[[StreamedRunResult[AgentDepsT, OutputDataT]], AsyncIterator[T]],
733
) -> Iterator[T]:
734
async def my_task():
735
- async with self._with_streamed_run_result() as result:
736
- async for item in func(result):
737
- yield item
+ try:
+ async with self._with_streamed_run_result() as result:
+ async for item in func(result):
738
+ yield item
739
+ except RuntimeError as e:
740
+ if str(e) != 'Attempted to exit cancel scope in a different task than it was entered in':
741
+ raise
742
743
return _utils.sync_async_iterator(my_task())
744
0 commit comments