RuntimeError: dictionary changed size during iteration #764 - Step 2

This commit is contained in:
Nicolargo 2016-01-04 15:08:36 +01:00
parent a3d27131e9
commit 8e2a255a31
2 changed files with 21 additions and 3 deletions

View File

@ -43,6 +43,15 @@ if PY3:
viewvalues = operator.methodcaller('values')
viewitems = operator.methodcaller('items')
def listitems(d):
return list(d.items())
def listkeys(d):
return list(d.keys())
def listvalues(d):
return list(d.values())
def iteritems(d):
return iter(d.items())
@ -82,6 +91,15 @@ else:
viewvalues = operator.methodcaller('viewvalues')
viewitems = operator.methodcaller('viewitems')
def listitems(d):
return d.items()
def listkeys(d):
return d.keys()
def listvalues(d):
return d.values()
def iteritems(d):
return d.iteritems()

View File

@ -27,7 +27,7 @@ import json
from datetime import datetime
from operator import itemgetter
from glances.compat import iterkeys, itervalues, map, viewkeys
from glances.compat import iterkeys, itervalues, listkeys, map
from glances.actions import GlancesActions
from glances.logger import logger
from glances.logs import glances_logs
@ -289,7 +289,7 @@ class GlancesPlugin(object):
# Stats are stored in a list of dict (ex: NETWORK, FS...)
for i in self.get_raw():
ret[i[self.get_key()]] = {}
for key in viewkeys(i):
for key in listkeys(i):
value = {'decoration': 'DEFAULT',
'optional': False,
'additional': False,
@ -297,7 +297,7 @@ class GlancesPlugin(object):
ret[i[self.get_key()]][key] = value
elif isinstance(self.get_raw(), dict) and self.get_raw() is not None:
# Stats are stored in a dict (ex: CPU, LOAD...)
for key in viewkeys(self.get_raw()):
for key in listkeys(self.get_raw()):
value = {'decoration': 'DEFAULT',
'optional': False,
'additional': False,