From b82363bc747586f531d8e5240de2559685e708de Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Fri, 7 Feb 2014 20:45:13 +0100 Subject: [PATCH] Sync openstack/common/memorycache.py with Oslo This fixes an issue in Client.get(), where a dictionary was modified as we iterated on its keys, which does not work in Python 3. Change-Id: I37583504dcc672060a3d780dce46418baa32dd53 --- keystoneclient/openstack/common/memorycache.py | 6 ++---- openstack-common.conf | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/keystoneclient/openstack/common/memorycache.py b/keystoneclient/openstack/common/memorycache.py index 18d2cf3ae..589048e94 100644 --- a/keystoneclient/openstack/common/memorycache.py +++ b/keystoneclient/openstack/common/memorycache.py @@ -1,5 +1,3 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. @@ -57,11 +55,11 @@ class Client(object): def get(self, key): """Retrieves the value for a key or None. - this expunges expired keys during each get + This expunges expired keys during each get. """ now = timeutils.utcnow_ts() - for k in self.cache.keys(): + for k in list(self.cache): (timeout, _value) = self.cache[k] if timeout and now >= timeout: del self.cache[k] diff --git a/openstack-common.conf b/openstack-common.conf index 9cd093d08..a7bbe9e7a 100644 --- a/openstack-common.conf +++ b/openstack-common.conf @@ -4,6 +4,7 @@ module=importutils module=install_venv_common module=jsonutils +module=memorycache module=strutils module=timeutils module=py3kcompat