[eventlet-removal] rewrite wait_until_true function
there's no reason to use eventlet for basic 'wait for true' function,
all the tests are running syncronously one by one anyway
(in separate worker processes at most), and merely importing eventlet
can have some unexpected side-effects (for example [0]).
[0] https://storyboard.openstack.org/#!/story/2010902
Change-Id: I9178d9acc8d88e2ddb8fba1111f12a5d2681e33e
Signed-off-by: Pavlo Shchelokovskyy <shchelokovskyy@gmail.com>
diff --git a/neutron_tempest_plugin/common/utils.py b/neutron_tempest_plugin/common/utils.py
index 4ae374e..5d6a26a 100644
--- a/neutron_tempest_plugin/common/utils.py
+++ b/neutron_tempest_plugin/common/utils.py
@@ -25,7 +25,6 @@
except ImportError:
from urllib import parse as urlparse
-import eventlet
from neutron_lib._i18n import _
from oslo_log import log
from tempest.lib import exceptions
@@ -79,15 +78,14 @@
:param exception: Exception instance to raise on timeout. If None is passed
(default) then WaitTimeout exception is raised.
"""
- try:
- with eventlet.Timeout(timeout):
- while not predicate():
- eventlet.sleep(sleep)
- except eventlet.Timeout:
- if exception is not None:
- # pylint: disable=raising-bad-type
- raise exception
- raise WaitTimeout(_("Timed out after %d seconds" % timeout))
+ start_time = time.time()
+ while not predicate():
+ elapsed_time = time.time() - start_time
+ if elapsed_time > timeout:
+ raise exception if exception else WaitTimeout(
+ _("Timed out after %d seconds") % timeout
+ )
+ time.sleep(sleep)
def override_class(overriden_class, overrider_class):
diff --git a/requirements.txt b/requirements.txt
index 957f186..478c1fa 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -12,5 +12,4 @@
tenacity>=3.2.1 # Apache-2.0
ddt>=1.0.1 # MIT
testtools>=2.2.0 # MIT
-eventlet>=0.21.0 # MIT
debtcollector>=1.2.0 # Apache-2.0
diff --git a/tox.ini b/tox.ini
index e209d58..5f4d1e9 100644
--- a/tox.ini
+++ b/tox.ini
@@ -64,7 +64,7 @@
# N530 direct neutron imports not allowed
# N535 prevent eventlet library import
# W504 line break after binary operator
-ignore = E126,E128,E129,I202,N530,N535,W504
+ignore = E126,E128,E129,I202,N530,W504
# H106: Don't put vim configuration in source files
# H203: Use assertIs(Not)None to check for None
# H204: Use assert(Not)Equal to check for equality