Allow handlers list to be modifed while iterating

This commit is contained in:
Philipp Hörist 2018-12-18 14:08:27 +01:00
parent ac9bec3ed9
commit d7bc92706d
1 changed files with 3 additions and 1 deletions

View File

@ -87,7 +87,9 @@ class GlobalEventsDispatcher:
log.debug('%s Args: %s', event_name, str(args))
if event_name in self.handlers:
node_processed = False
for _priority, handler in self.handlers[event_name]:
# Iterate over a copy of the handlers list, so while iterating
# the original handlers list can be modified
for _priority, handler in list(self.handlers[event_name]):
try:
if handler(*args, **kwargs):
return True