revert the way we remove websockets in a list

This commit is contained in:
Kay0u 2021-06-17 16:13:10 +02:00
parent 84df910e20
commit 657810edc3
No known key found for this signature in database
GPG key ID: AAFEEB16CFA2AE2D

5
run.py
View file

@ -470,13 +470,16 @@ async def broadcast(message, channels):
for channel in channels:
ws_list = subscriptions[channel]
dead_ws = []
for ws in ws_list:
try:
await ws.send(json.dumps(message, default=datetime_to_epoch_json_converter))
except ConnectionClosed:
ws_list.remove(ws)
dead_ws.append(ws)
for to_remove in dead_ws:
ws_list.remove(to_remove)
def subscribe(ws, channel):
subscriptions[channel].append(ws)