[Core] Fix bug when emiting event in EventManager
In some cases, when emiting events with EventManager.emit_event(), the underlying dictionary of interested sessions can change during iteration, causing: RuntimeError: dictionary changed size during iteration Fix by iterating over a copy of the dictionary. Closes: https://dev.deluge-torrent.org/ticket/3351 Closes: https://github.com/deluge-torrent/deluge/pull/425
This commit is contained in:
parent
e70e43e631
commit
89b79e4b7f
|
@ -545,8 +545,8 @@ class RPCServer(component.Component):
|
|||
:type event: :class:`deluge.event.DelugeEvent`
|
||||
"""
|
||||
log.debug('intevents: %s', self.factory.interested_events)
|
||||
# Find sessions interested in this event
|
||||
for session_id, interest in self.factory.interested_events.items():
|
||||
# Use copy of `interested_events` since it can mutate while iterating.
|
||||
for session_id, interest in self.factory.interested_events.copy().items():
|
||||
if event.name in interest:
|
||||
log.debug('Emit Event: %s %s', event.name, event.args)
|
||||
# This session is interested so send a RPC_EVENT
|
||||
|
|
Loading…
Reference in New Issue