Skip to content

Commit

Permalink
Docs. Correct Producer pattern example.
Browse files Browse the repository at this point in the history
  • Loading branch information
idlesign authored and aaugustin committed Mar 2, 2025
1 parent 5fa24bb commit fce02ab
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/howto/patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ To send messages to the WebSocket connection::
from websockets.exceptions import ConnectionClosed

async def producer_handler(websocket):
try:
while True:
while True:
try:
message = await produce()
await websocket.send(message)
except ConnectionClosed:
break
except ConnectionClosed:
break

In this example, ``produce()`` is a coroutine implementing your business logic
for generating the next message to send on the WebSocket connection.
Expand Down

0 comments on commit fce02ab

Please sign in to comment.