summaryrefslogtreecommitdiff
path: root/taskflow/utils
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-01-29 08:37:19 +0000
committerGerrit Code Review <review@openstack.org>2015-01-29 08:37:19 +0000
commit708b01ec1240b5d28c19e4a8bf99f1a3d7c4912f (patch)
tree943c03397f34a2154beab7fc428768f8d56bc2e6 /taskflow/utils
parentc6bfb36d25dcf90716bc2501eb1ec169bf10d1e2 (diff)
parent97797abb518f6b73f4165206bac73e770f4d1aa3 (diff)
downloadtaskflow-708b01ec1240b5d28c19e4a8bf99f1a3d7c4912f.tar.gz
Merge "Use importutils.try_import for optional eventlet imports"
Diffstat (limited to 'taskflow/utils')
-rw-r--r--taskflow/utils/async_utils.py6
-rw-r--r--taskflow/utils/eventlet_utils.py10
2 files changed, 7 insertions, 9 deletions
diff --git a/taskflow/utils/async_utils.py b/taskflow/utils/async_utils.py
index 71eafa1..e04c44e 100644
--- a/taskflow/utils/async_utils.py
+++ b/taskflow/utils/async_utils.py
@@ -16,11 +16,9 @@
from concurrent import futures as _futures
from concurrent.futures import _base
+from oslo_utils import importutils
-try:
- from eventlet.green import threading as greenthreading
-except ImportError:
- pass
+greenthreading = importutils.try_import('eventlet.green.threading')
from taskflow.types import futures
from taskflow.utils import eventlet_utils as eu
diff --git a/taskflow/utils/eventlet_utils.py b/taskflow/utils/eventlet_utils.py
index 68dd355..2f5a42a 100644
--- a/taskflow/utils/eventlet_utils.py
+++ b/taskflow/utils/eventlet_utils.py
@@ -14,11 +14,11 @@
# License for the specific language governing permissions and limitations
# under the License.
-try:
- import eventlet as _eventlet # noqa
- EVENTLET_AVAILABLE = True
-except ImportError:
- EVENTLET_AVAILABLE = False
+from oslo_utils import importutils
+
+_eventlet = importutils.try_import('eventlet')
+
+EVENTLET_AVAILABLE = bool(_eventlet)
def check_for_eventlet(exc=None):