From bac396992985b0b64d02236bb3ccb78b31fc3d49 Mon Sep 17 00:00:00 2001 From: gordon chung Date: Tue, 2 Feb 2016 18:05:32 -0500 Subject: [PATCH] support ability to set thread pool size per listener it'd be nice to support listeners with different threading requirements. e.g. 1 listener that pulls from a queue with no ordering requirements, therefore, able to handle multiple threads. another listener that pulls from queue with sequential requirements, therefore, requires a single thread process all data, in order. Change-Id: Id3af696193af2ccf5e5f3a1ae1d22f4f80860606 --- oslo_messaging/_executors/impl_pooledexecutor.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/oslo_messaging/_executors/impl_pooledexecutor.py b/oslo_messaging/_executors/impl_pooledexecutor.py index f442c3ae9..0934bb4e8 100644 --- a/oslo_messaging/_executors/impl_pooledexecutor.py +++ b/oslo_messaging/_executors/impl_pooledexecutor.py @@ -104,9 +104,13 @@ class PooledExecutor(base.ExecutorBase): if not was_submitted: break - def start(self): + def start(self, override_pool_size=None): if self._executor is None: + if override_pool_size is not None and int(override_pool_size) < 1: + raise ValueError('The thread pool size should be a positive ' + 'value.') self._executor = self._executor_cls( + override_pool_size if override_pool_size else self.conf.executor_thread_pool_size) self._tombstone.clear() if self._poller is None or not self._poller.is_alive():