diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-07 22:07:35 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-07 22:07:35 +0000 |
| commit | 849ec9d88a61e6df5ad7bf671e33869b869aaad5 (patch) | |
| tree | 543e0526bd278edce9e6a217bc6c98865f66732e | |
| parent | f3d28abb2ed3ea4e3d8c3bf424ea9df8232cfa6a (diff) | |
| parent | 67f74991f73fa2c8350c434a7f67c85bf50e4934 (diff) | |
| download | nova-849ec9d88a61e6df5ad7bf671e33869b869aaad5.tar.gz nova-849ec9d88a61e6df5ad7bf671e33869b869aaad5.tar.xz nova-849ec9d88a61e6df5ad7bf671e33869b869aaad5.zip | |
Merge "Stop lock decorator from leaving tempdirs in tests"
| -rw-r--r-- | nova/utils.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/nova/utils.py b/nova/utils.py index 889138d89..31d62a611 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -717,14 +717,14 @@ def synchronized(name, external=False, lock_path=None): {'lock': name, 'method': f.__name__}) cleanup_dir = False - def wrap_mkdtemp(): - cleanup_dir = True - return tempfile.mkdtemp() - # We need a copy of lock_path because it is non-local local_lock_path = lock_path if not local_lock_path: - local_lock_path = FLAGS.lock_path or wrap_mkdtemp() + local_lock_path = FLAGS.lock_path + + if not local_lock_path: + cleanup_dir = True + local_lock_path = tempfile.mkdtemp() if not os.path.exists(local_lock_path): cleanup_dir = True @@ -735,8 +735,8 @@ def synchronized(name, external=False, lock_path=None): safe_name = name.replace(os.sep, '_') lock_file_path = os.path.join(local_lock_path, 'nova-%s' % safe_name) - lock = InterProcessLock(lock_file_path) try: + lock = InterProcessLock(lock_file_path) with lock: LOG.debug(_('Got file lock "%(lock)s" for ' 'method "%(method)s"...'), |
