diff --git a/oslo_messaging/_drivers/impl_zmq.py b/oslo_messaging/_drivers/impl_zmq.py index 6108e9519..e11383661 100644 --- a/oslo_messaging/_drivers/impl_zmq.py +++ b/oslo_messaging/_drivers/impl_zmq.py @@ -465,7 +465,8 @@ class ZmqBaseReactor(ConsumerBase): self.sockets = [] self.subscribe = {} - self.pool = eventlet.greenpool.GreenPool(conf.rpc_thread_pool_size) + self.pool = eventlet.greenpool.GreenPool( + conf.executor_thread_pool_size) def register(self, proxy, in_addr, zmq_type_in, in_bind=True, subscribe=None): diff --git a/oslo_messaging/_executors/impl_pooledexecutor.py b/oslo_messaging/_executors/impl_pooledexecutor.py index c9531acff..68743368c 100644 --- a/oslo_messaging/_executors/impl_pooledexecutor.py +++ b/oslo_messaging/_executors/impl_pooledexecutor.py @@ -25,9 +25,10 @@ from oslo_utils import excutils from oslo_messaging._executors import base _pool_opts = [ - cfg.IntOpt('rpc_thread_pool_size', + cfg.IntOpt('executor_thread_pool_size', default=64, - help='Size of RPC thread pool.'), + deprecated_name="rpc_thread_pool_size", + help='Size of executor thread pool.'), ] @@ -103,7 +104,8 @@ class PooledExecutor(base.ExecutorBase): def start(self): if self._executor is None: - self._executor = self._executor_cls(self.conf.rpc_thread_pool_size) + self._executor = self._executor_cls( + self.conf.executor_thread_pool_size) self._tombstone.clear() if self._poller is None or not self._poller.is_alive(): self._poller = self._thread_cls(target=self._runner) diff --git a/oslo_messaging/opts.py b/oslo_messaging/opts.py index 1f065b5ea..267b7ec16 100644 --- a/oslo_messaging/opts.py +++ b/oslo_messaging/opts.py @@ -76,3 +76,23 @@ def list_opts(): :returns: a list of (group_name, opts) tuples """ return [(g, copy.deepcopy(o)) for g, o in _opts] + + +def set_defaults(conf, executor_thread_pool_size=None): + """Set defaults for configuration variables. + + Overrides default options values. + + :param conf: Config instance specified to set default options in it. Using + of instances instead of a global config object prevents conflicts between + options declaration. + :type conf: oslo.config.cfg.ConfigOpts instance. + + :keyword executor_thread_pool_size: Size of executor thread pool. + :type executor_thread_pool_size: int + :default executor_thread_pool_size: None + + """ + if executor_thread_pool_size is not None: + conf.set_default('executor_thread_pool_size', + executor_thread_pool_size) diff --git a/oslo_messaging/tests/test_opts.py b/oslo_messaging/tests/test_opts.py index d1c75a0bc..5e4f241f9 100644 --- a/oslo_messaging/tests/test_opts.py +++ b/oslo_messaging/tests/test_opts.py @@ -15,6 +15,9 @@ import stevedore import testtools +import mock + +from oslo_messaging._executors import impl_thread try: from oslo_messaging import opts except ImportError: @@ -55,3 +58,8 @@ class OptsTestCase(test_utils.BaseTestCase): self.assertIsNotNone(result) self._test_list_opts(result) + + def test_defaults(self): + impl_thread.ThreadExecutor(self.conf, mock.Mock(), mock.Mock()) + opts.set_defaults(self.conf, executor_thread_pool_size=100) + self.assertEqual(100, self.conf.executor_thread_pool_size)