Skip to content

Commit

Permalink
update: samples/3catchall/main.py to handle exception in case of webs…
Browse files Browse the repository at this point in the history
…ocket.
  • Loading branch information
itaru2622 committed Sep 22, 2024
1 parent 0e1d8df commit 577cf58
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions samples/3catchall/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ async def catch_websocket(ws:WebSocket, full_path: str):
input = { "full_path": full_path, "query": dict(ws._query_params), "headers": dict(ws._headers) }
await ws.send_text(f'new websocket connection: {input}')
while True:
msg = await ws.receive_text()
await ws.send_text(f'got: {msg}')
try:
msg = await ws.receive_text()
await ws.send_text(f'got: {msg}')
except:
break

0 comments on commit 577cf58

Please sign in to comment.