Added thread pool for eventlet executor mode

Change-Id: I78c43cfa530c7f1721b3281a0afeea585ff35251
This commit is contained in:
Vitalii Solodilov 2018-04-08 16:10:50 +04:00
parent 54fe5b0109
commit e01daded0f
3 changed files with 19 additions and 13 deletions

View File

@ -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)

View File

@ -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):

View File

@ -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