diff options
author | John L. Villalovos <john.l.villalovos@intel.com> | 2015-10-22 08:30:12 -0700 |
---|---|---|
committer | John L. Villalovos <john.l.villalovos@intel.com> | 2015-10-23 06:20:37 -0700 |
commit | 874b54d4784e3e41ad1751e9ccb8f1bf7f7da24e (patch) | |
tree | 772dfb88bac8ce2a7d175f7aac2cae925caa87c6 | |
parent | fc51cc9939f774c836521580bde9d3ea3d4e1d52 (diff) | |
download | ironic-874b54d4784e3e41ad1751e9ccb8f1bf7f7da24e.tar.gz |
Use self.__class__.X instead of self.X
The variable '_hash_rings' is being referenced by both
self.__class__._hash_rings (for assigning) and self._hash_rings (for
reading).
Instead use only self.__class__._hash_rings to be consistent. This
should be less confusing. Before the reader had to know the scoping
rules and that reading self._hash_rings was actually reading
self.__class__._hash_rings. But assigning to self._hash_rings would
create a new instance variable instead of updating the class level
self.__class__._hash_rings.
This change will hopefully make the code easier to read and understand.
Change-Id: I6c38962ee6c8d6b341a04efaffa8e7a0f53bfbe5
-rw-r--r-- | ironic/common/hash_ring.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/ironic/common/hash_ring.py b/ironic/common/hash_ring.py index baeb95743..20304d394 100644 --- a/ironic/common/hash_ring.py +++ b/ironic/common/hash_ring.py @@ -177,15 +177,15 @@ class HashRingManager(object): interval = CONF.hash_ring_reset_interval limit = time.time() - interval # Hot path, no lock - if self._hash_rings is not None and self.updated_at >= limit: - return self._hash_rings + if self.__class__._hash_rings is not None and self.updated_at >= limit: + return self.__class__._hash_rings with self._lock: - if self._hash_rings is None or self.updated_at < limit: + if self.__class__._hash_rings is None or self.updated_at < limit: rings = self._load_hash_rings() self.__class__._hash_rings = rings self.updated_at = time.time() - return self._hash_rings + return self.__class__._hash_rings def _load_hash_rings(self): rings = {} |