summaryrefslogtreecommitdiff
path: root/taskflow/engines/worker_based
diff options
context:
space:
mode:
authorJoshua Harlow <harlowja@yahoo-inc.com>2015-03-13 14:29:34 -0700
committerJoshua Harlow <harlowja@yahoo-inc.com>2015-03-18 14:50:59 -0700
commit22fd32fb55d45b5f355a862b2edd78fde3c2086f (patch)
tree19dd4de4b27f229f38eca6c67a2add352f369212 /taskflow/engines/worker_based
parent2232c5a88db56093aefca0c919a6ff2e73709559 (diff)
downloadtaskflow-22fd32fb55d45b5f355a862b2edd78fde3c2086f.tar.gz
Just let the future executors handle the max workers
Instead of providing and retaining a thread count in the worker and action engine executors and checking it and handling the none case, we can just let the future types handle this already (which they already do). And when displaying this information in the worker banner use a new future executor attribute that is the maximum number of workers that will be ever created. Change-Id: I765c22936b53cdbb8a90195a764d4c67bcc3f34b
Diffstat (limited to 'taskflow/engines/worker_based')
-rw-r--r--taskflow/engines/worker_based/worker.py13
1 files changed, 5 insertions, 8 deletions
diff --git a/taskflow/engines/worker_based/worker.py b/taskflow/engines/worker_based/worker.py
index 5e9ff85..8a79133 100644
--- a/taskflow/engines/worker_based/worker.py
+++ b/taskflow/engines/worker_based/worker.py
@@ -98,13 +98,9 @@ System details:
self._topic = topic
self._executor = executor
self._owns_executor = False
- self._threads_count = -1
if self._executor is None:
- if threads_count is not None:
- self._threads_count = int(threads_count)
- else:
- self._threads_count = tu.get_optimal_thread_count()
- self._executor = futures.ThreadPoolExecutor(self._threads_count)
+ self._executor = futures.ThreadPoolExecutor(
+ max_workers=threads_count)
self._owns_executor = True
self._endpoints = self._derive_endpoints(tasks)
self._exchange = exchange
@@ -139,8 +135,9 @@ System details:
tpl_params['transport_type'] = transport.driver_type
tpl_params['connection_uri'] = connection_details.uri
tpl_params['executor_type'] = reflection.get_class_name(self._executor)
- if self._threads_count != -1:
- tpl_params['executor_thread_count'] = self._threads_count
+ threads_count = getattr(self._executor, 'max_workers', None)
+ if threads_count is not None:
+ tpl_params['executor_thread_count'] = threads_count
if self._endpoints:
pretty_endpoints = []
for ep in self._endpoints: