From c166c181bfedc3e467aa9e2e788b155d16b7c19d Mon Sep 17 00:00:00 2001 From: Torsten Werner Date: Sun, 4 Jul 2010 17:17:24 +0000 Subject: [PATCH] introduce defaultThreadCount ... make it an int and let it default to 1 (single threading) Signed-off-by: Torsten Werner --- daklib/threadpool.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/daklib/threadpool.py b/daklib/threadpool.py index 41ae3431..5b17e3c4 100644 --- a/daklib/threadpool.py +++ b/daklib/threadpool.py @@ -15,6 +15,11 @@ except NameError: False = 0 True = not False +if Config().has_key('Common::ThreadCount'): + defaultThreadCount = int(Config()['Common::ThreadCount']) +else: + defaultThreadCount = 1 + class ThreadPool: """Flexible thread pool class. Creates a pool of threads, then @@ -22,10 +27,13 @@ class ThreadPool: The argument numThreads defaults to 'Common::ThreadCount' which must be specified in dak.conf.""" - def __init__(self, numThreads = Config()['Common::ThreadCount']): + def __init__(self, numThreads = 0): """Initialize the thread pool with numThreads workers.""" + if numThreads == 0: + numThreads = defaultThreadCount + self.__threads = [] self.__resizeLock = threading.Condition(threading.Lock()) self.__taskLock = threading.Condition(threading.Lock()) -- 2.39.5