Skip to content

Commit beb8f2c

Browse files
docstrings
1 parent b92db6d commit beb8f2c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

sentry_sdk/integrations/anthropic.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,8 @@ def _wrap_stream_iter(
802802
) -> "Callable[..., Iterator[RawMessageStreamEvent]]":
803803
"""
804804
Accumulates output data while iterating. When the returned iterator ends, set
805-
output attributes on the AI Client Span and end the span.
805+
output attributes on the AI Client Span and ends the span (unless the `close()`
806+
or `__next__()` patches have already closed it).
806807
"""
807808

808809
def __iter__(self: "Stream") -> "Iterator[RawMessageStreamEvent]":
@@ -824,6 +825,7 @@ def _wrap_stream_next(
824825
) -> "Callable[..., RawMessageStreamEvent]":
825826
"""
826827
Accumulates output data from the returned event.
828+
Closes the AI Client Span if `StopIteration` is raised.
827829
"""
828830

829831
def __next__(self: "Stream") -> "RawMessageStreamEvent":
@@ -858,7 +860,8 @@ def _wrap_stream_close(
858860
f: "Callable[..., None]",
859861
) -> "Callable[..., None]":
860862
"""
861-
Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` runs first.
863+
Closes the AI Client Span, unless the finally block in `_wrap_synchronous_message_iterator()` or
864+
the except block in the `__next__()` patch runs first.
862865
"""
863866

864867
def close(self: "Stream") -> None:

0 commit comments

Comments
 (0)