monkey patch stdlib before importing other modules
Some oslo libraries assume that stdlib is already patched when they are imported (e.g. oslo_concurrency.processutils tests the 'time' module for monkey_patching to detect which 'subprocess' module to import. This can cause issues when things like test frameworks import modules that monkey_patch, as the order imports are made can break this kind of check. It is always good to monkey patch as soon as possible, hence trying to do the patching in neutron/__init__.py. This is an alternative to https://review.openstack.org/#/c/153225/ which just patches neutron/tests/__init__.py. Unfortunately, just monkey_patching in tests/__init__.py didn't fix all of the issues I ran into. For example, tempest tests were failing with timeouts. Closes-bug: #1418541 Change-Id: I7f2115a99acae5b6d61aab2f7334f498b8d99858
This commit is contained in:
parent
e49abc9729
commit
24b11ded7f
|
@ -14,6 +14,11 @@
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
|
import os
|
||||||
|
|
||||||
|
if not os.environ.get('NO_EVENTLET'):
|
||||||
|
import eventlet
|
||||||
|
eventlet.monkey_patch()
|
||||||
|
|
||||||
|
|
||||||
gettext.install('neutron', unicode=1)
|
gettext.install('neutron', unicode=1)
|
||||||
|
|
|
@ -179,7 +179,7 @@ function warn_on_flake8_without_venv {
|
||||||
function run_pep8 {
|
function run_pep8 {
|
||||||
echo "Running flake8 ..."
|
echo "Running flake8 ..."
|
||||||
warn_on_flake8_without_venv
|
warn_on_flake8_without_venv
|
||||||
${wrapper} flake8
|
NO_EVENTLET=1 ${wrapper} flake8
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_pep8_changed {
|
function run_pep8_changed {
|
||||||
|
@ -192,7 +192,7 @@ function run_pep8_changed {
|
||||||
local files=$(git diff --name-only $target | tr '\n' ' ')
|
local files=$(git diff --name-only $target | tr '\n' ' ')
|
||||||
echo "Running flake8 on ${files}"
|
echo "Running flake8 on ${files}"
|
||||||
warn_on_flake8_without_venv
|
warn_on_flake8_without_venv
|
||||||
diff -u --from-file /dev/null ${files} | ${wrapper} flake8 --diff
|
diff -u --from-file /dev/null ${files} | NO_EVENTLET=1 ${wrapper} flake8 --diff
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
1
tox.ini
1
tox.ini
|
@ -49,6 +49,7 @@ sitepackages = True
|
||||||
downloadcache = ~/cache/pip
|
downloadcache = ~/cache/pip
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
|
setenv = NO_EVENTLET=1
|
||||||
commands =
|
commands =
|
||||||
# If it is easier to add a check via a shell script, consider adding it in this file
|
# If it is easier to add a check via a shell script, consider adding it in this file
|
||||||
sh ./tools/misc-sanity-checks.sh
|
sh ./tools/misc-sanity-checks.sh
|
||||||
|
|
Loading…
Reference in New Issue