diff options
| author | Ewan Mellor <ewan.mellor@citrix.com> | 2010-07-28 21:23:11 +0100 |
|---|---|---|
| committer | Ewan Mellor <ewan.mellor@citrix.com> | 2010-07-28 21:23:11 +0100 |
| commit | 77117b6a3b89ea9e2cd8a7422a6268784f930168 (patch) | |
| tree | ebd8fc7447e2bdd320d22117ed6fe75c37749268 | |
| parent | 1a53eaeed901f3c789ebdb867b73996ccac608c3 (diff) | |
| parent | 5c3d352cee5003395d078dcfe01e8f4743027074 (diff) | |
| download | nova-77117b6a3b89ea9e2cd8a7422a6268784f930168.tar.gz nova-77117b6a3b89ea9e2cd8a7422a6268784f930168.tar.xz nova-77117b6a3b89ea9e2cd8a7422a6268784f930168.zip | |
Merged lp:~vishvananda/nova/lp609749.
| -rw-r--r-- | nova/process.py | 13 | ||||
| -rw-r--r-- | nova/tests/process_unittest.py | 2 |
2 files changed, 8 insertions, 7 deletions
diff --git a/nova/process.py b/nova/process.py index 8ecef1584..2dc56372f 100644 --- a/nova/process.py +++ b/nova/process.py @@ -205,12 +205,13 @@ class ProcessPool(object): self._pool.release() return rv -_instance = None -def SharedPool(): - global _instance - if _instance is None: - _instance = ProcessPool() - return _instance +class SharedPool(object): + _instance = None + def __init__(self): + if SharedPool._instance is None: + self.__class__._instance = ProcessPool() + def __getattr__(self, key): + return getattr(self._instance, key) def simple_execute(cmd, **kwargs): return SharedPool().simple_execute(cmd, **kwargs) diff --git a/nova/tests/process_unittest.py b/nova/tests/process_unittest.py index c96bb5913..75187e1fc 100644 --- a/nova/tests/process_unittest.py +++ b/nova/tests/process_unittest.py @@ -118,7 +118,7 @@ class ProcessTestCase(test.TrialTestCase): def test_shared_pool_is_singleton(self): pool1 = process.SharedPool() pool2 = process.SharedPool() - self.assert_(id(pool1) == id(pool2)) + self.assertEqual(id(pool1._instance), id(pool2._instance)) def test_shared_pool_works_as_singleton(self): d1 = process.simple_execute('sleep 1') |
