Skip to content

Commit 577cf58

Browse files
committed
update: samples/3catchall/main.py to handle exception in case of websocket.
1 parent 0e1d8df commit 577cf58

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

samples/3catchall/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ async def catch_websocket(ws:WebSocket, full_path: str):
2727
input = { "full_path": full_path, "query": dict(ws._query_params), "headers": dict(ws._headers) }
2828
await ws.send_text(f'new websocket connection: {input}')
2929
while True:
30-
msg = await ws.receive_text()
31-
await ws.send_text(f'got: {msg}')
30+
try:
31+
msg = await ws.receive_text()
32+
await ws.send_text(f'got: {msg}')
33+
except:
34+
break

0 commit comments

Comments
 (0)