server: skip duplicate response on CancelledError (#1153)
Co-authored-by: ihrpr <inna@anthropic.com>
This commit is contained in:
parent
35777b9811
commit
b34e7207ad
1 changed files with 117 additions and 0 deletions
|
|
@ -647,6 +647,12 @@ class Server(Generic[LifespanResultT, RequestT]):
|
|||
response = await handler(req)
|
||||
except McpError as err:
|
||||
response = err.error
|
||||
except anyio.get_cancelled_exc_class():
|
||||
logger.info(
|
||||
"Request %s cancelled - duplicate response suppressed",
|
||||
message.request_id,
|
||||
)
|
||||
return
|
||||
except Exception as err:
|
||||
if raise_exceptions:
|
||||
raise err
|
||||
|
|
|
|||
Loading…
Reference in a new issue