From 7826a96e526a450380917f9b89e3714576ca50b7 Mon Sep 17 00:00:00 2001 From: Victor Shyba Date: Wed, 27 May 2015 18:51:44 -0300 Subject: [bug] use dict keys to iterate We ran into a RuntimeError yesterday on this line, the callback can modify this dict and make the iteration raise an error. Using keys method to iterate is safer. See http://stackoverflow.com/questions/11941817/python-runtimeerror-dictionary-changed-size-during-iteration-how-to-avoid-th/11941855#11941855 --- src/leap/common/events/client.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/leap') diff --git a/src/leap/common/events/client.py b/src/leap/common/events/client.py index 6b234a1..0706fe3 100644 --- a/src/leap/common/events/client.py +++ b/src/leap/common/events/client.py @@ -184,7 +184,7 @@ class EventsClient(object): :type msg: list(str) """ logger.debug("Handling event %s..." % event) - for uid in self._callbacks[event]: + for uid in self._callbacks[event].keys(): callback = self._callbacks[event][uid] logger.debug("Executing callback %s." % uid) callback(event, *content) @@ -352,7 +352,6 @@ class EventsClientThread(threading.Thread, EventsClient): """ self._sub.socket.setsockopt(zmq.SUBSCRIBE, tag) - def _unsubscribe(self, tag): """ Unsubscribe from a tag on the zmq SUB socket. -- cgit v1.2.3