// Grab this before the "for" loop, so it doesn"t change while
// we loop through its elements.
browser_queues = list(self._browser_queues.items())
for ws, browser_queue in browser_queues:
while len(browser_queue):
msg = browser_queue.popleft()
After Change
msg_list = browser_queue.flush()
for msg in msg_list:
msg_str = _serialize(msg)
if ws is None:
break
ws.write_message(msg_str, binary=True)
yield
yield