We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 5fa24bb commit fce02abCopy full SHA for fce02ab
docs/howto/patterns.rst
@@ -38,12 +38,12 @@ To send messages to the WebSocket connection::
38
from websockets.exceptions import ConnectionClosed
39
40
async def producer_handler(websocket):
41
- try:
42
- while True:
+ while True:
+ try:
43
message = await produce()
44
await websocket.send(message)
45
- except ConnectionClosed:
46
- break
+ except ConnectionClosed:
+ break
47
48
In this example, ``produce()`` is a coroutine implementing your business logic
49
for generating the next message to send on the WebSocket connection.
0 commit comments