From e01daded0f030fd87d41960dd90fdcc862595d99 Mon Sep 17 00:00:00 2001 From: Vitalii Solodilov Date: Sun, 8 Apr 2018 16:10:50 +0400 Subject: [PATCH] Added thread pool for eventlet executor mode Change-Id: I78c43cfa530c7f1721b3281a0afeea585ff35251 --- mistral/rpc/kombu/kombu_server.py | 2 +- .../tests/unit/rpc/kombu/test_kombu_server.py | 29 +++++++++++-------- setup.cfg | 1 + 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/mistral/rpc/kombu/kombu_server.py b/mistral/rpc/kombu/kombu_server.py index 6e92671fe..e55782ffd 100644 --- a/mistral/rpc/kombu/kombu_server.py +++ b/mistral/rpc/kombu/kombu_server.py @@ -285,7 +285,7 @@ class KombuRPCServer(rpc_base.RPCServer, kombu_base.Base): executor_opts = {} - if executor == 'threading': + if executor != 'blocking': executor_opts['max_workers'] = self._executor_threads self._worker = mgr.driver(**executor_opts) diff --git a/mistral/tests/unit/rpc/kombu/test_kombu_server.py b/mistral/tests/unit/rpc/kombu/test_kombu_server.py index 51e88f739..c74448da3 100644 --- a/mistral/tests/unit/rpc/kombu/test_kombu_server.py +++ b/mistral/tests/unit/rpc/kombu/test_kombu_server.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +import futurist from mistral import context from mistral import exceptions as exc from mistral.tests.unit.rpc.kombu import base @@ -279,20 +280,24 @@ class KombuServerTestCase(base.KombuTestCase): correlation_id ) - @mock.patch('stevedore.driver.DriverManager') - def test__prepare_worker(self, driver_manager_mock): - worker_mock = mock.MagicMock() - mgr_mock = mock.MagicMock() - mgr_mock.driver.return_value = worker_mock - - def side_effect(*args, **kwargs): - return mgr_mock - - driver_manager_mock.side_effect = side_effect - + def test__prepare_worker(self): self.server._prepare_worker('blocking') + self.assertEqual( + futurist.SynchronousExecutor, + type(self.server._worker) + ) - self.assertEqual(self.server._worker, worker_mock) + self.server._prepare_worker('threading') + self.assertEqual( + futurist.ThreadPoolExecutor, + type(self.server._worker) + ) + + self.server._prepare_worker('eventlet') + self.assertEqual( + futurist.GreenThreadPoolExecutor, + type(self.server._worker) + ) @mock.patch('stevedore.driver.DriverManager') def test__prepare_worker_no_valid_executor(self, driver_manager_mock): diff --git a/setup.cfg b/setup.cfg index caab0062c..b39cf707f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -110,6 +110,7 @@ mistral.auth = kombu_driver.executors = blocking = futurist:SynchronousExecutor threading = futurist:ThreadPoolExecutor + eventlet = futurist:GreenThreadPoolExecutor pygments.lexers = mistral = mistral.ext.pygmentplugin:MistralLexer