Skip to content

Commit 8e9bfab

Browse files
docstrings
1 parent 288a065 commit 8e9bfab

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

sentry_sdk/integrations/anthropic.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -929,7 +929,8 @@ def _wrap_async_stream_aiter(
929929
) -> "Callable[..., AsyncIterator[RawMessageStreamEvent]]":
930930
"""
931931
Accumulates output data while iterating. When the returned iterator ends, set
932-
output attributes on the AI Client Span and end the span.
932+
output attributes on the AI Client Span and ends the span (unless the `close()`
933+
or `__next__()` patches have already closed it).
933934
"""
934935

935936
async def __aiter__(self: "AsyncStream") -> "AsyncIterator[RawMessageStreamEvent]":
@@ -953,6 +954,7 @@ def _wrap_async_stream_anext(
953954
) -> "Callable[..., Awaitable[RawMessageStreamEvent]]":
954955
"""
955956
Accumulates output data from the returned event.
957+
Closes the AI Client Span if `StopIteration` is raised.
956958
"""
957959

958960
async def __anext__(self: "AsyncStream") -> "RawMessageStreamEvent":
@@ -987,7 +989,8 @@ def _wrap_async_stream_close(
987989
f: "Callable[..., Awaitable[None]]",
988990
) -> "Callable[..., Awaitable[None]]":
989991
"""
990-
Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` runs first.
992+
Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` or
993+
the except block in the `__next__()` patch runs first.
991994
"""
992995

993996
async def close(self: "Stream") -> None:
@@ -1268,7 +1271,8 @@ def _wrap_async_message_stream_aiter(
12681271
) -> "Callable[..., AsyncIterator[MessageStreamEvent]]":
12691272
"""
12701273
Accumulates output data while iterating. When the returned iterator ends, set
1271-
output attributes on the AI Client Span and end the span.
1274+
output attributes on the AI Client Span and ends the span (unless the `close()`
1275+
or `__next__()` patches have already closed it).
12721276
"""
12731277

12741278
async def __aiter__(
@@ -1294,6 +1298,7 @@ def _wrap_async_message_stream_anext(
12941298
) -> "Callable[..., Awaitable[MessageStreamEvent]]":
12951299
"""
12961300
Accumulates output data from the returned event.
1301+
Closes the AI Client Span if `StopIteration` is raised.
12971302
"""
12981303

12991304
async def __anext__(self: "AsyncMessageStream") -> "MessageStreamEvent":
@@ -1328,7 +1333,8 @@ def _wrap_async_message_stream_close(
13281333
f: "Callable[..., Awaitable[None]]",
13291334
) -> "Callable[..., Awaitable[None]]":
13301335
"""
1331-
Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` runs first.
1336+
Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` or
1337+
the except block in the `__next__()` patch runs first.
13321338
"""
13331339

13341340
async def close(self: "AsyncMessageStream") -> None:

0 commit comments

Comments
 (0)