Skip to content

Instantly share code, notes, and snippets.

@gofman
Created February 24, 2022 18:11
Show Gist options
  • Save gofman/863f295effd6dc2be692c2c480c4225f to your computer and use it in GitHub Desktop.
Save gofman/863f295effd6dc2be692c2c480c4225f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import asyncio
import websockets
async def fragmented_reply(websocket, path):
print("Client connected")
await websocket.send(["fragment1", "fragment2", "fragment3"])
print("Reply sent")
event_loop = asyncio.new_event_loop()
asyncio.set_event_loop(event_loop)
server = websockets.serve(fragmented_reply, '0.0.0.0', 12345)
event_loop.run_until_complete(server)
event_loop.run_forever()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment