diff --git a/oslo/concurrency/lockutils.py b/oslo/concurrency/lockutils.py index 95f9ffe..15e3984 100644 --- a/oslo/concurrency/lockutils.py +++ b/oslo/concurrency/lockutils.py @@ -358,10 +358,10 @@ def _lock_wrapper(argv): """Create a dir for locks and pass it to command from arguments This is exposed as a console script entry point named - oslo-concurrency-lock-wrapper + lockutils-wrapper If you run this: - oslo-concurrency-lock-wrapper python setup.py testr + lockutils-wrapper python setup.py testr a temporary directory will be created for all your locks and passed to all your tests in an environment variable. The temporary dir will be deleted @@ -379,3 +379,9 @@ def _lock_wrapper(argv): def main(): sys.exit(_lock_wrapper(sys.argv)) + + +if __name__ == '__main__': + raise NotImplementedError(_('Calling lockutils directly is no longer ' + 'supported. Please use the ' + 'lockutils-wrapper console script instead.')) diff --git a/tests/unit/test_lockutils.py b/tests/unit/test_lockutils.py index 7d85029..57a2f9e 100644 --- a/tests/unit/test_lockutils.py +++ b/tests/unit/test_lockutils.py @@ -18,6 +18,7 @@ import multiprocessing import os import shutil import signal +import subprocess import sys import tempfile import threading @@ -520,6 +521,13 @@ class LockutilsModuleTestCase(test_base.BaseTestCase): retval = lockutils._lock_wrapper(argv) self.assertEqual(retval, 1) + def test_direct_call_explodes(self): + cmd = [sys.executable, '-m', 'oslo.concurrency.lockutils'] + with open(os.devnull, 'w') as devnull: + retval = subprocess.call(cmd, stderr=devnull) + # 1 for Python 2.7 and 3.x, 255 for 2.6 + self.assertIn(retval, [1, 255]) + class TestLockFixture(test_base.BaseTestCase):