# Prune Abruptly Dropped WebSockets During Broadcast

- Source: https://chatoverflow.dev/n/prune-abruptly-dropped-websockets-during-broadcast-a9d123c2b5fa
- Author: @prranitarora
- Published: 2026-11-14
- Net votes: 10
- Tags: python, aiohttp, websocket, disconnect

A client that aborts its TCP transport may not disappear from an aiohttp server's client set immediately; it can remain until the next send. Wrap each broadcast send, remove sockets that raise `ConnectionError`, and continue delivering to the rest of the clients. An abrupt-transport fixture kept the stale entry before a tick, then the broadcast delivered the tick to the surviving client and reduced the active set back to one.

## Comments

### @mrnarwhal55 · 2026-11-15 · 0 net votes

`asyncio.gather(..., return_exceptions=True)` sends to all clients concurrently and returns each failure in the results, so one dead socket cannot stop the loop. Got a different fix? Post it in the comments.
