summaryrefslogtreecommitdiffstats
path: root/openstack/common/local.py
diff options
context:
space:
mode:
authorMichael Still <mikal@stillhq.com>2012-10-25 10:13:53 +1100
committerMichael Still <mikal@stillhq.com>2013-02-06 12:43:33 +1100
commit51efba78bdcee821937c28c1973ec80e8c2d59ae (patch)
treefaa4b454fe361b71187e07b4ed71ecaa29b24bdc /openstack/common/local.py
parenta9b69ff076080e31271d32751580c35107f0a451 (diff)
downloadoslo-51efba78bdcee821937c28c1973ec80e8c2d59ae.tar.gz
oslo-51efba78bdcee821937c28c1973ec80e8c2d59ae.tar.xz
oslo-51efba78bdcee821937c28c1973ec80e8c2d59ae.zip
Emit a warning if RPC calls made with lock.
This patch will log a warning every time a RPC call is made while a lock is held if the caller has requested it. This should help us track down performance problems such as the security group refresh problem recently found in nova. RPC calls can emit a warning if called with check_for_lock=True and debugging is turned on. Sneaks up on bug 1063222. Change-Id: Ice94093efb3cb95dd58b31d6ba817c7d505c15af
Diffstat (limited to 'openstack/common/local.py')
-rw-r--r--openstack/common/local.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/openstack/common/local.py b/openstack/common/local.py
index 19d9627..8bdc837 100644
--- a/openstack/common/local.py
+++ b/openstack/common/local.py
@@ -26,6 +26,9 @@ class WeakLocal(corolocal.local):
def __getattribute__(self, attr):
rval = corolocal.local.__getattribute__(self, attr)
if rval:
+ # NOTE(mikal): this bit is confusing. What is stored is a weak
+ # reference, not the value itself. We therefore need to lookup
+ # the weak reference and return the inner value here.
rval = rval()
return rval
@@ -34,4 +37,12 @@ class WeakLocal(corolocal.local):
return corolocal.local.__setattr__(self, attr, value)
+# NOTE(mikal): the name "store" should be deprecated in the future
store = WeakLocal()
+
+# A "weak" store uses weak references and allows an object to fall out of scope
+# when it falls out of scope in the code that uses the thread local storage. A
+# "strong" store will hold a reference to the object so that it never falls out
+# of scope.
+weak_store = WeakLocal()
+strong_store = corolocal.local