Skip to content

Commit 9773477

Browse files
author
Alan Christie
committed
fix: close() now adds a reason
1 parent 71252c0 commit 9773477

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

app/app.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,15 @@ async def event_stream(websocket: WebSocket, uuid: str):
173173
message_body = await reader
174174
_LOGGER.debug("Got message for %s (message_body=%s)", es_id, message_body)
175175
if message_body == b"POISON":
176-
_LOGGER.debug("Got poison pill for %s (%s) (closing)...", es_id, uuid)
176+
_LOGGER.debug("Taking POISON for %s (%s) (closing)...", es_id, uuid)
177177
_running = False
178178
else:
179179
await websocket.send_text(str(message_body))
180180

181181
_LOGGER.debug("Closing %s (uuid=%s)...", es_id, uuid)
182-
await websocket.close()
182+
await websocket.close(
183+
code=status.WS_1000_NORMAL_CLOSURE, reason="The stream has been deleted"
184+
)
183185
_LOGGER.debug("Closed %s", es_id)
184186

185187

0 commit comments

Comments
 (0)