Skip to content

Handle client list size changing on websocket send

What does this MR do and why?

Fix Crafty crash for client list changing while sending websockets

Screenshots or screen recordings

Exception in thread command_watcher:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/var/opt/minecraft/crafty/crafty-4/app/classes/shared/tasks.py", line 118, in command_watcher
    svr.restart_threaded_server(user_id)
  File "/var/opt/minecraft/crafty/crafty-4/app/classes/shared/server.py", line 674, in restart_threaded_server
    self.stop_threaded_server()
  File "/var/opt/minecraft/crafty/crafty-4/app/classes/shared/server.py", line 584, in stop_threaded_server
    self.stop_server()
  File "/var/opt/minecraft/crafty/crafty-4/app/classes/shared/server.py", line 660, in stop_server
    self.helper.websocket_helper.broadcast_user(user, "send_start_reload", {})
  File "/var/opt/minecraft/crafty/crafty-4/app/classes/web/websocket_helper.py", line 49, in broadcast_user
    self.broadcast_with_fn(filter_fn, event_type, data)
  File "/var/opt/minecraft/crafty/crafty-4/app/classes/web/websocket_helper.py", line 88, in broadcast_with_fn
    clients = list(filter(filter_fn, self.clients))
RuntimeError: Set changed size during iteration

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

  • Have you checked this doesn't interfere/conflict/duplicate someone elses work?
  • Have you fully tested your changes?
  • Have you resolved any lint issues?
  • Have you assigned a reviewer?
  • Have you applied correct labels?
Edited by Iain Powrie

Merge request reports

Loading