diff options
| author | Soren Hansen <soren@linux2go.dk> | 2011-03-01 20:54:51 +0100 |
|---|---|---|
| committer | Soren Hansen <soren@linux2go.dk> | 2011-03-01 20:54:51 +0100 |
| commit | 8b66f2f57bb267db228fde24e5773c3c5391b8b4 (patch) | |
| tree | 59ccef2a0f1bd65677ce54dbcf68f9d1f5f2b03a | |
| parent | d40bbc512fdf2f11584a57957d184b2d8137c2ba (diff) | |
| parent | be9004ffa4c70358c8edda1f33ffe7ba7e1ae1ee (diff) | |
| download | nova-8b66f2f57bb267db228fde24e5773c3c5391b8b4.tar.gz nova-8b66f2f57bb267db228fde24e5773c3c5391b8b4.tar.xz nova-8b66f2f57bb267db228fde24e5773c3c5391b8b4.zip | |
Merge sync branch.
| -rw-r--r-- | nova/tests/test_misc.py | 12 | ||||
| -rw-r--r-- | nova/utils.py | 6 |
2 files changed, 14 insertions, 4 deletions
diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py index 154b6fae6..9f572b58e 100644 --- a/nova/tests/test_misc.py +++ b/nova/tests/test_misc.py @@ -14,11 +14,9 @@ # License for the specific language governing permissions and limitations # under the License. -from datetime import datetime import errno import os import select -import time from nova import test from nova.utils import parse_mailmap, str_dict_replace, synchronized @@ -62,6 +60,16 @@ class ProjectTestCase(test.TestCase): class LockTestCase(test.TestCase): + def test_synchronized_wrapped_function_metadata(self): + @synchronized('whatever') + def foo(): + """Bar""" + pass + self.assertEquals(foo.__doc__, 'Bar', "Wrapped function's docstring " + "got lost") + self.assertEquals(foo.__name__, 'foo', "Wrapped function's name " + "got mangled") + def test_synchronized(self): rpipe, wpipe = os.pipe() pid = os.fork() diff --git a/nova/utils.py b/nova/utils.py index 7b004253d..829adfb9e 100644 --- a/nova/utils.py +++ b/nova/utils.py @@ -23,11 +23,14 @@ System-level utilities and helper functions. import base64 import datetime +import functools import inspect import json import lockfile +import netaddr import os import random +import re import socket import string import struct @@ -35,8 +38,6 @@ import sys import time import types from xml.sax import saxutils -import re -import netaddr from eventlet import event from eventlet import greenthread @@ -505,6 +506,7 @@ def loads(s): def synchronized(name): def wrap(f): + @functools.wraps(f) def inner(*args, **kwargs): lock = lockfile.FileLock(os.path.join(FLAGS.lock_path, 'nova-%s.lock' % name)) |
