summaryrefslogtreecommitdiff
path: root/oslo_concurrency
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-10-02 01:43:15 +0000
committerGerrit Code Review <review@openstack.org>2016-10-02 01:43:15 +0000
commit14f103960e008a5c4ac6ffe13160ef53774ffff9 (patch)
treefb260ee81b46c839538e323046ffa74b5bae0746 /oslo_concurrency
parent5063e92634347feb8d7bf5776099f8c66c3e695c (diff)
parent70ff5511053bc7070c071f46978b1ff59b89c4b5 (diff)
downloadoslo-concurrency-14f103960e008a5c4ac6ffe13160ef53774ffff9.tar.gz
Merge "Ignore prlimit argument on Windows"
Diffstat (limited to 'oslo_concurrency')
-rw-r--r--oslo_concurrency/processutils.py15
-rw-r--r--oslo_concurrency/tests/unit/test_processutils.py22
2 files changed, 32 insertions, 5 deletions
diff --git a/oslo_concurrency/processutils.py b/oslo_concurrency/processutils.py
index 808ae2a..7fa294e 100644
--- a/oslo_concurrency/processutils.py
+++ b/oslo_concurrency/processutils.py
@@ -327,11 +327,16 @@ def execute(*cmd, **kwargs):
cmd = [str(c) for c in cmd]
if prlimit:
- args = [sys.executable, '-m', 'oslo_concurrency.prlimit']
- args.extend(prlimit.prlimit_args())
- args.append('--')
- args.extend(cmd)
- cmd = args
+ if os.name == 'nt':
+ LOG.log(loglevel,
+ _('Process resource limits are ignored as '
+ 'this feature is not supported on Windows.'))
+ else:
+ args = [sys.executable, '-m', 'oslo_concurrency.prlimit']
+ args.extend(prlimit.prlimit_args())
+ args.append('--')
+ args.extend(cmd)
+ cmd = args
sanitized_cmd = strutils.mask_password(' '.join(cmd))
diff --git a/oslo_concurrency/tests/unit/test_processutils.py b/oslo_concurrency/tests/unit/test_processutils.py
index 7f68be3..e5ef532 100644
--- a/oslo_concurrency/tests/unit/test_processutils.py
+++ b/oslo_concurrency/tests/unit/test_processutils.py
@@ -895,3 +895,25 @@ class PrlimitTestCase(test_base.BaseTestCase):
self.assertIn(expected, exc.stderr)
else:
self.fail("ProcessExecutionError not raised")
+
+ @mock.patch.object(os, 'name', 'nt')
+ @mock.patch.object(processutils.subprocess, "Popen")
+ def test_prlimit_windows(self, mock_popen):
+ # We want to ensure that process resource limits are
+ # ignored on Windows, in which case this feature is not
+ # supported. We'll just check the command passed to Popen,
+ # which is expected to be unaltered.
+ prlimit = self.limit_address_space()
+ mock_popen.return_value.communicate.return_value = None
+
+ processutils.execute(
+ *self.SIMPLE_PROGRAM,
+ prlimit=prlimit,
+ check_exit_code=False)
+
+ mock_popen.assert_called_once_with(
+ self.SIMPLE_PROGRAM,
+ stdin=mock.ANY, stdout=mock.ANY,
+ stderr=mock.ANY, close_fds=mock.ANY,
+ preexec_fn=mock.ANY, shell=mock.ANY,
+ cwd=mock.ANY, env=mock.ANY)