Skip to content

Commit bc65733

Browse files
Zuulopenstack-gerrit
authored andcommitted
Merge "Remove explicit use of eventlet"
2 parents 0b9d710 + ae002a3 commit bc65733

File tree

4 files changed

+11
-15
lines changed

4 files changed

+11
-15
lines changed

networking_generic_switch/batching.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@
1414

1515
import atexit
1616
import json
17+
import threading
1718

1819
import etcd3gw
1920
from etcd3gw import exceptions as etcd3gw_exc
2021
from etcd3gw.utils import _decode
2122
from etcd3gw.utils import _encode
2223
from etcd3gw.utils import _increment_last_byte
23-
import eventlet
2424
from oslo_log import log as logging
25+
from oslo_service import threadgroup
2526
from oslo_utils import netutils
2627
from oslo_utils import uuidutils
2728
import tenacity
@@ -32,7 +33,7 @@
3233

3334
LOG = logging.getLogger(__name__)
3435

35-
THREAD_POOL = eventlet.greenpool.GreenPool()
36+
THREAD_POOL = threadgroup.ThreadGroup()
3637

3738

3839
class ShutdownTimeout(Exception):
@@ -48,12 +49,12 @@ def _wait_for_threads():
4849
and performing switch configuration operations which should not be
4950
interrupted.
5051
"""
52+
active_threads = len(THREAD_POOL.threads)
5153
LOG.info("Waiting %d seconds for %d threads to complete",
52-
SHUTDOWN_TIMEOUT, THREAD_POOL.running())
54+
SHUTDOWN_TIMEOUT, active_threads)
5355
try:
54-
with eventlet.Timeout(SHUTDOWN_TIMEOUT, ShutdownTimeout):
55-
THREAD_POOL.waitall()
56-
except ShutdownTimeout:
56+
THREAD_POOL.stop(graceful=True, timeout=SHUTDOWN_TIMEOUT)
57+
except Exception:
5758
LOG.error("Timed out waiting for threads to complete")
5859
else:
5960
LOG.info("Finished waiting for threads to complete")
@@ -365,13 +366,12 @@ def do_work():
365366

366367
@staticmethod
367368
def _spawn(work_fn):
368-
# TODO(johngarbutt) remove hard eventlet dependency
369-
# in a similar way to etcd3gw
370369
# Sleep to let possible other work to batch together
371-
eventlet.sleep(0)
370+
# This works with both eventlet and native threading
371+
threading.Event().wait(0.001)
372372
# Run all pending tasks, which might be a no op
373373
# if pending tasks already ran
374-
THREAD_POOL.spawn_n(work_fn)
374+
THREAD_POOL.add_thread(work_fn)
375375

376376
def _execute_pending_batches(self, device, item):
377377
"""Execute all batches currently registered.

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# date but we do not test them so no guarantee of having them all correct. If
33
# you find any incorrect lower bounds, let us know or propose a fix.
44
etcd3gw>=2.1.0 # Apache-2.0
5-
eventlet>=0.18.2 # Apache-2.0
5+
oslo.service[threading]>=4.2.0 # Apache-2.0
66
stevedore>=1.20.0 # Apache-2.0
77
netmiko>=4.1.1 # MIT
88
neutron>=13.0.0.0b1 # Apache-2.0

tools/ngs-stress/ngs_stress.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,12 @@
1818
import threading
1919
import uuid
2020

21-
import eventlet
2221
from neutron_lib.utils import net
2322
from oslo_config import cfg
2423
import oslo_log.log as logging
2524

2625
import networking_generic_switch.generic_switch_mech as generic_switch
2726

28-
eventlet.monkey_patch()
29-
3027
CONF = cfg.CONF
3128
LOG = logging.getLogger(__name__)
3229

tox.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ envlist = py3,pep8
44
ignore_basepython_conflict=true
55

66
[testenv]
7-
constrain_package_deps = true
87
usedevelop = True
98
setenv = VIRTUAL_ENV={envdir}
109
PYTHONDONTWRITEBYTECODE = 1

0 commit comments

Comments
 (0)