File tree Expand file tree Collapse file tree 1 file changed +10
-9
lines changed
Expand file tree Collapse file tree 1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -444,15 +444,16 @@ async def _receive_loop(self) -> None:
444444 finally :
445445 # after the read stream is closed, we need to send errors
446446 # to any pending requests
447- for id , stream in self ._response_streams .items ():
448- error = ErrorData (code = CONNECTION_CLOSED , message = "Connection closed" )
449- try :
450- await stream .send (JSONRPCError (jsonrpc = "2.0" , id = id , error = error ))
451- await stream .aclose ()
452- except Exception : # pragma: no cover
453- # Stream might already be closed
454- pass
455- self ._response_streams .clear ()
447+ with anyio .CancelScope (shield = True ):
448+ for id , stream in self ._response_streams .items ():
449+ error = ErrorData (code = CONNECTION_CLOSED , message = "Connection closed" )
450+ try :
451+ await stream .send (JSONRPCError (jsonrpc = "2.0" , id = id , error = error ))
452+ await stream .aclose ()
453+ except Exception : # pragma: no cover
454+ # Stream might already be closed
455+ pass
456+ self ._response_streams .clear ()
456457
457458 def _normalize_request_id (self , response_id : RequestId ) -> RequestId :
458459 """
You can’t perform that action at this time.
0 commit comments