File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -345,10 +345,19 @@ async def event_stream(
345345 offset_specification = offset_specification ,
346346 )
347347
348- # One our way out...
349- await websocket .close (
350- code = status .WS_1000_NORMAL_CLOSURE , reason = "The stream has been deleted"
351- )
348+ # On our way out...
349+ try :
350+ await websocket .close (
351+ code = status .WS_1000_NORMAL_CLOSURE , reason = "The stream has been deleted"
352+ )
353+ except RuntimeError :
354+ # There's a chance we encounter a RuntimeError
355+ # with the message 'RuntimeError: Cannot call "send" once a close message has been sent.'
356+ # We don't care - we have to just get out of here
357+ # so errors in tear-down have to be ignored,
358+ # and there's no apparent way to know whether calling 'close()' is safe.
359+ _LOGGER .debug ("Ignoring RuntimeError from close() for %s" , es_id )
360+
352361 _LOGGER .info ("Closed WebSocket for %s (uuid=%s)" , es_id , uuid )
353362
354363
You can’t perform that action at this time.
0 commit comments