fix: prevent async generator cleanup errors in StreamableHTTP transport (#1271)
Some checks failed
Main branch checks / checks (push) Has been cancelled
Some checks failed
Main branch checks / checks (push) Has been cancelled
Co-authored-by: David Soria Parra <167242713+dsp-ant@users.noreply.github.com>
This commit is contained in:
parent
0926613714
commit
d1ac8d68eb
1 changed files with 2 additions and 0 deletions
|
|
@ -248,6 +248,7 @@ class StreamableHTTPTransport:
|
|||
ctx.metadata.on_resumption_token_update if ctx.metadata else None,
|
||||
)
|
||||
if is_complete:
|
||||
await event_source.response.aclose()
|
||||
break
|
||||
|
||||
async def _handle_post_request(self, ctx: RequestContext) -> None:
|
||||
|
|
@ -330,6 +331,7 @@ class StreamableHTTPTransport:
|
|||
# If the SSE event indicates completion, like returning respose/error
|
||||
# break the loop
|
||||
if is_complete:
|
||||
await response.aclose()
|
||||
break
|
||||
except Exception as e:
|
||||
logger.exception("Error reading SSE stream:")
|
||||
|
|
|
|||
Loading…
Reference in a new issue