From cfef69e34e3eda4f019a00a2d84ff3d6e5288a1d Mon Sep 17 00:00:00 2001 From: zhurong Date: Wed, 8 Jul 2020 16:25:18 +0800 Subject: [PATCH] Murano api add monkey patch In this commit [0] has monkey patching should be as early as possible, but didn't monkey patch murano api, this will cause the RecursionError [0]: I76fed9e80a7f848a0f6b37c25dd035844c75a6ee Change-Id: Idf8ab02b15459d4dc786389c583afb752c599cb6 Closes-Bug: #1886784 (cherry picked from commit ae9b4e8099a31e2a45e1a1ed0f225f50f34ca394) --- murano/api/__init__.py | 14 ++++++++++++++ murano/cmd/__init__.py | 14 ++++++++++++++ murano/cmd/api.py | 9 --------- murano/cmd/cfapi.py | 9 --------- murano/cmd/engine.py | 9 --------- murano/monkey_patch.py | 25 +++++++++++++++++++++++++ 6 files changed, 53 insertions(+), 27 deletions(-) create mode 100644 murano/monkey_patch.py diff --git a/murano/api/__init__.py b/murano/api/__init__.py index e69de29bb..a9bd720ac 100644 --- a/murano/api/__init__.py +++ b/murano/api/__init__.py @@ -0,0 +1,14 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import murano.monkey_patch # noqa diff --git a/murano/cmd/__init__.py b/murano/cmd/__init__.py index e69de29bb..a9bd720ac 100644 --- a/murano/cmd/__init__.py +++ b/murano/cmd/__init__.py @@ -0,0 +1,14 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import murano.monkey_patch # noqa diff --git a/murano/cmd/api.py b/murano/cmd/api.py index 91c17cb06..6383c97cc 100644 --- a/murano/cmd/api.py +++ b/murano/cmd/api.py @@ -18,8 +18,6 @@ import os import sys -import eventlet - from oslo_concurrency import processutils from oslo_config import cfg from oslo_log import log as logging @@ -36,13 +34,6 @@ from murano.common import wsgi CONF = cfg.CONF -if os.name == 'nt': - # eventlet monkey patching causes subprocess.Popen to fail on Windows - # when using pipes due to missing non blocking I/O support - eventlet.monkey_patch(os=False) -else: - eventlet.monkey_patch() - # If ../murano/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir) diff --git a/murano/cmd/cfapi.py b/murano/cmd/cfapi.py index 9bfd922e4..29504cdbb 100644 --- a/murano/cmd/cfapi.py +++ b/murano/cmd/cfapi.py @@ -17,8 +17,6 @@ import os import sys -import eventlet - from oslo_config import cfg from oslo_log import log as logging from oslo_service import service @@ -32,13 +30,6 @@ from murano.common import wsgi CONF = cfg.CONF -if os.name == 'nt': - # eventlet monkey patching causes subprocess.Popen to fail on Windows - # when using pipes due to missing non blocking I/O support - eventlet.monkey_patch(os=False) -else: - eventlet.monkey_patch() - # If ../murano/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir) diff --git a/murano/cmd/engine.py b/murano/cmd/engine.py index 260af903a..6a8592be3 100644 --- a/murano/cmd/engine.py +++ b/murano/cmd/engine.py @@ -17,8 +17,6 @@ import os import sys -import eventlet - from oslo_concurrency import processutils from oslo_log import log as logging from oslo_service import service @@ -29,13 +27,6 @@ from murano.common import engine CONF = config.CONF -if os.name == 'nt': - # eventlet monkey patching causes subprocess.Popen to fail on Windows - # when using pipes due to missing non blocking I/O support - eventlet.monkey_patch(os=False) -else: - eventlet.monkey_patch() - # If ../murano/__init__.py exists, add ../ to Python search path, so that # it will override what happens to be installed in /usr/(local/)lib/python... root = os.path.join(os.path.abspath(__file__), os.pardir, os.pardir, os.pardir) diff --git a/murano/monkey_patch.py b/murano/monkey_patch.py new file mode 100644 index 000000000..28ec5f60c --- /dev/null +++ b/murano/monkey_patch.py @@ -0,0 +1,25 @@ +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +import os + +import eventlet + + +if os.name == 'nt': + # eventlet monkey patching causes subprocess.Popen to fail on Windows + # when using pipes due to missing non blocking I/O support + eventlet.monkey_patch(os=False) +else: + eventlet.monkey_patch()