fix runtime error: dict changed size during iteration
This commit is contained in:
parent
8051235171
commit
e54ed5b10e
@ -140,7 +140,7 @@ class ChannelManager:
|
|||||||
Disconnect all Channels
|
Disconnect all Channels
|
||||||
"""
|
"""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
for websocket, channel in self.channels.items():
|
for websocket, channel in self.channels.copy().items():
|
||||||
if not channel.is_closed():
|
if not channel.is_closed():
|
||||||
await channel.close()
|
await channel.close()
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class ChannelManager:
|
|||||||
"""
|
"""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
message_type = data.get('type')
|
message_type = data.get('type')
|
||||||
for websocket, channel in self.channels.items():
|
for websocket, channel in self.channels.copy().items():
|
||||||
try:
|
try:
|
||||||
if channel.subscribed_to(message_type):
|
if channel.subscribed_to(message_type):
|
||||||
await channel.send(data)
|
await channel.send(data)
|
||||||
|
Loading…
Reference in New Issue
Block a user