Use eventlet-aware threading events
For the gory details behind this, see: https://bugzilla.redhat.com/show_bug.cgi?id=1384183 In summary, if you use threading.Event on python2 with eventlet, it unnecessarily spams system calls to epoll_wait and burns a *lot* of CPU cycles by constantly context-switching. I added eventletutils.Event to oslo_utils a while back to intelligently use the eventlet Event object when eventlet is being used, and to fall back to the threading one otherwise. So just use that and it will do the right thing. Depends-On: https://review.openstack.org/#/c/558879/ Change-Id: I6ca0d0fc2a2ff393bab502a5f705fb0d63c32c6b
This commit is contained in:
parent
5131444a62
commit
b97b24856f
@ -80,7 +80,7 @@ oslo.middleware==3.31.0
|
||||
oslo.policy==1.30.0
|
||||
oslo.serialization==2.18.0
|
||||
oslo.service==1.24.0
|
||||
oslo.utils==3.33.0
|
||||
oslo.utils==3.37.0
|
||||
oslosphinx==4.7.0
|
||||
oslotest==3.2.0
|
||||
osprofiler==1.4.0
|
||||
|
@ -19,6 +19,7 @@ import six
|
||||
import threading
|
||||
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import eventletutils
|
||||
|
||||
from mistral.rpc.kombu import base as kombu_base
|
||||
|
||||
@ -34,7 +35,7 @@ class KombuRPCListener(ConsumerMixin):
|
||||
self._thread = None
|
||||
self.connection = six.next(self._connections)
|
||||
|
||||
self.ready = threading.Event()
|
||||
self.ready = eventletutils.Event()
|
||||
|
||||
def add_listener(self, correlation_id):
|
||||
self._results[correlation_id] = six.moves.queue.Queue()
|
||||
|
@ -20,6 +20,7 @@ import time
|
||||
import kombu
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from oslo_utils import eventletutils
|
||||
from stevedore import driver
|
||||
|
||||
from mistral import context as auth_ctx
|
||||
@ -68,8 +69,8 @@ class KombuRPCServer(rpc_base.RPCServer, kombu_base.Base):
|
||||
self.routing_key = self.topic
|
||||
self.channel = None
|
||||
self.conn = None
|
||||
self._running = threading.Event()
|
||||
self._stopped = threading.Event()
|
||||
self._running = eventletutils.Event()
|
||||
self._stopped = eventletutils.Event()
|
||||
self.endpoints = []
|
||||
self._worker = None
|
||||
self._thread = None
|
||||
|
@ -24,7 +24,7 @@ oslo.i18n>=3.15.3 # Apache-2.0
|
||||
oslo.messaging>=5.29.0 # Apache-2.0
|
||||
oslo.middleware>=3.31.0 # Apache-2.0
|
||||
oslo.policy>=1.30.0 # Apache-2.0
|
||||
oslo.utils>=3.33.0 # Apache-2.0
|
||||
oslo.utils>=3.37.0 # Apache-2.0
|
||||
oslo.log>=3.36.0 # Apache-2.0
|
||||
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
|
||||
oslo.service!=1.28.1,>=1.24.0 # Apache-2.0
|
||||
|
Loading…
Reference in New Issue
Block a user