]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
openstack_container.py: improve name of _auth_lock; simplify by using DeferredLock...
authorDavid-Sarah Hopwood <david-sarah@jacaranda.org>
Fri, 15 Feb 2013 20:59:06 +0000 (20:59 +0000)
committerDaira Hopwood <daira@jacaranda.org>
Wed, 9 Apr 2014 00:33:55 +0000 (01:33 +0100)
Signed-off-by: David-Sarah Hopwood <david-sarah@jacaranda.org>
src/allmydata/storage/backends/cloud/openstack/openstack_container.py

index 0aa2099677acb444083c829610a55e0670e5fd11..b1b400526d8b1414d4ae720b8aac3b9138aee982 100644 (file)
@@ -77,7 +77,7 @@ class AuthenticationClient(object):
 
         # Not authorized yet.
         self._auth_info = None
-        self._first_auth_lock = defer.DeferredLock()
+        self._auth_lock = defer.DeferredLock()
         d = self.get_auth_info()
         d.addBoth(lambda ign: None)
 
@@ -89,12 +89,7 @@ class AuthenticationClient(object):
             return self.get_auth_info_locked()
 
     def get_auth_info_locked(self, suppress_errors=False):
-        d = self._first_auth_lock.acquire()
-        d.addCallback(self._authenticate)
-        def _release(res):
-            self._first_auth_lock.release()
-            return res
-        d.addBoth(_release)
+        d = self._auth_lock.run(self._authenticate)
         d.addCallback(lambda ign: self._auth_info)
         if suppress_errors:
             d.addErrback(lambda ign: self._auth_info)