mirror of
https://github.com/YunoHost/yunorunner.git
synced 2024-09-03 20:05:52 +02:00
revert the way we remove websockets in a list
This commit is contained in:
parent
84df910e20
commit
657810edc3
1 changed files with 4 additions and 1 deletions
5
run.py
5
run.py
|
@ -470,13 +470,16 @@ async def broadcast(message, channels):
|
||||||
|
|
||||||
for channel in channels:
|
for channel in channels:
|
||||||
ws_list = subscriptions[channel]
|
ws_list = subscriptions[channel]
|
||||||
|
dead_ws = []
|
||||||
|
|
||||||
for ws in ws_list:
|
for ws in ws_list:
|
||||||
try:
|
try:
|
||||||
await ws.send(json.dumps(message, default=datetime_to_epoch_json_converter))
|
await ws.send(json.dumps(message, default=datetime_to_epoch_json_converter))
|
||||||
except ConnectionClosed:
|
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):
|
def subscribe(ws, channel):
|
||||||
subscriptions[channel].append(ws)
|
subscriptions[channel].append(ws)
|
||||||
|
|
Loading…
Add table
Reference in a new issue