From 22e822dde29dd68c5868f615629b84b53841c4e6 Mon Sep 17 00:00:00 2001 From: songwenping Date: Fri, 28 May 2021 01:52:20 +0000 Subject: [PATCH] Remove references to sys.version_info We support Python 3.6 as a minimum now, making these checks no-ops. Change-Id: Ia4b1eec7a788cb1ede3dc338f7be7e5d8a84069d --- mistral/scheduler/default_scheduler.py | 8 -------- mistral/services/action_heartbeat_checker.py | 8 -------- mistral/services/action_heartbeat_sender.py | 8 -------- mistral/services/legacy_scheduler.py | 8 -------- mistral/tests/unit/base.py | 14 ++------------ tools/install_venv.py | 1 - tools/install_venv_common.py | 4 ---- 7 files changed, 2 insertions(+), 49 deletions(-) diff --git a/mistral/scheduler/default_scheduler.py b/mistral/scheduler/default_scheduler.py index c54b3adcf..759b85ce0 100644 --- a/mistral/scheduler/default_scheduler.py +++ b/mistral/scheduler/default_scheduler.py @@ -16,7 +16,6 @@ import copy import datetime import eventlet import random -import sys import threading from oslo_config import cfg @@ -97,13 +96,6 @@ class DefaultScheduler(base.Scheduler): " due to unexpected exception." ) - # For some mysterious reason (probably eventlet related) - # the exception is not cleared from the context automatically. - # This results in subsequent log.warning calls to show invalid - # info. - if sys.version_info < (3,): - sys.exc_clear() - def _process_store_jobs(self): # Select and capture eligible jobs. with db_api.transaction(): diff --git a/mistral/services/action_heartbeat_checker.py b/mistral/services/action_heartbeat_checker.py index 94190df54..218766b94 100644 --- a/mistral/services/action_heartbeat_checker.py +++ b/mistral/services/action_heartbeat_checker.py @@ -14,7 +14,6 @@ import datetime import eventlet -import sys from mistral import context as auth_ctx from mistral.db import utils as db_utils @@ -92,13 +91,6 @@ def _loop(): ' due to an unexpected exception.' ) - # For some mysterious reason (probably eventlet related) - # the exception is not cleared from the context automatically. - # This results in subsequent log.warning calls to show invalid - # info. - if sys.version_info < (3,): - sys.exc_clear() - eventlet.sleep(CONF.action_heartbeat.check_interval) diff --git a/mistral/services/action_heartbeat_sender.py b/mistral/services/action_heartbeat_sender.py index 00b7e819d..dc08bbfa3 100644 --- a/mistral/services/action_heartbeat_sender.py +++ b/mistral/services/action_heartbeat_sender.py @@ -13,7 +13,6 @@ # limitations under the License. import eventlet -import sys from oslo_config import cfg from oslo_log import log as logging @@ -83,13 +82,6 @@ def _loop(): ' due to an unexpected exception.' ) - # For some mysterious reason (probably eventlet related) - # the exception is not cleared from the context automatically. - # This results in subsequent log.warning calls to show invalid - # info. - if sys.version_info < (3,): - sys.exc_clear() - eventlet.sleep(CONF.action_heartbeat.check_interval) diff --git a/mistral/services/legacy_scheduler.py b/mistral/services/legacy_scheduler.py index 6b6766fcc..55f34bf72 100644 --- a/mistral/services/legacy_scheduler.py +++ b/mistral/services/legacy_scheduler.py @@ -18,7 +18,6 @@ import copy import datetime import eventlet import random -import sys import threading from oslo_config import cfg @@ -148,13 +147,6 @@ class LegacyScheduler(sched_base.Scheduler): " due to unexpected exception." ) - # For some mysterious reason (probably eventlet related) - # the exception is not cleared from the context automatically. - # This results in subsequent log.warning calls to show invalid - # info. - if sys.version_info < (3,): - sys.exc_clear() - eventlet.sleep( self._fixed_delay + random.Random().randint(0, self._random_delay * 1000) * 0.001 diff --git a/mistral/tests/unit/base.py b/mistral/tests/unit/base.py index 2b000239b..0453560f9 100644 --- a/mistral/tests/unit/base.py +++ b/mistral/tests/unit/base.py @@ -16,14 +16,12 @@ import datetime import json import pkg_resources as pkg -import sys import time from unittest import mock from oslo_config import cfg from oslo_log import log as logging from oslotest import base -import testtools.matchers as ttm from mistral import context as auth_context from mistral.db.sqlalchemy import base as db_sa_base @@ -133,18 +131,10 @@ class BaseTest(base.BaseTestCase): self.assertIn(msg, e.message) def assertListEqual(self, l1, l2): - if tuple(sys.version_info)[0:2] < (2, 7): - # for python 2.6 compatibility - self.assertEqual(l1, l2) - else: - super(BaseTest, self).assertListEqual(l1, l2) + super(BaseTest, self).assertListEqual(l1, l2) def assertDictEqual(self, cmp1, cmp2): - if tuple(sys.version_info)[0:2] < (2, 7): - # for python 2.6 compatibility - self.assertThat(cmp1, ttm.Equals(cmp2)) - else: - super(BaseTest, self).assertDictEqual(cmp1, cmp2) + super(BaseTest, self).assertDictEqual(cmp1, cmp2) def _assert_single_item(self, items, **props): return self._assert_multiple_items(items, 1, **props)[0] diff --git a/tools/install_venv.py b/tools/install_venv.py index 45b36fd87..b0a784608 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -61,7 +61,6 @@ def main(argv): install = install_venv.InstallVenv(root, venv, pip_requires, test_requires, py_version, project) options = install.parse_args(argv) - install.check_python_version() install.check_dependencies() install.create_virtualenv(no_site_packages=options.no_site_packages) install.install_dependencies() diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py index e2127a769..35926eeeb 100644 --- a/tools/install_venv_common.py +++ b/tools/install_venv_common.py @@ -44,10 +44,6 @@ class InstallVenv(object): print(message % args, file=sys.stderr) sys.exit(1) - def check_python_version(self): - if sys.version_info < (2, 6): - self.die("Need Python Version >= 2.6") - def run_command_with_code(self, cmd, redirect_output=True, check_exit_code=True): """Runs a command in an out-of-process shell.