From cb064f95dfd01d5bed9541aaf4c81be437e8a98d Mon Sep 17 00:00:00 2001 From: Andrew Date: Sun, 2 Oct 2022 14:29:36 -0400 Subject: [PATCH 1/2] Fix set size changed during iteration --- app/classes/web/websocket_helper.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/classes/web/websocket_helper.py b/app/classes/web/websocket_helper.py index f7b26189..cd70df50 100644 --- a/app/classes/web/websocket_helper.py +++ b/app/classes/web/websocket_helper.py @@ -85,7 +85,10 @@ class WebSocketHelper: self.broadcast_with_fn(filter_fn, event_type, data) def broadcast_with_fn(self, filter_fn, event_type: str, data): - clients = list(filter(filter_fn, self.clients)) + # assign self.clients to a static variable here so hopefully + # the set size won't change + static_clients = self.clients + clients = list(filter(filter_fn, static_clients)) logger.debug( f"Sending to {len(clients)} out of {len(self.clients)} " f"clients: {json.dumps({'event': event_type, 'data': data})}" From a6b22c0fb8d3be060ca7078696b46875e2623b63 Mon Sep 17 00:00:00 2001 From: Zedifus Date: Sun, 2 Oct 2022 21:29:48 +0100 Subject: [PATCH 2/2] Update changelog !473 --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 488f8be2..5e7599cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Fix traceback on basic schedule with "days" interval ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/469)) - Fix bad method call with API stdin ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/470))
*(Thank you ['IWant2Tryhard'](https://github.com/MyNameTsThad) for catching that 🐛)* +- Fix clients variable as static to prevent crash if client list changed while sending a websocket ([Merge Request](https://gitlab.com/crafty-controller/crafty-4/-/merge_requests/473))

## --- [4.0.14] - 2022/09/23