From e14af00922ade40beac9cf578ad42f113eac5370 Mon Sep 17 00:00:00 2001 From: Daniel Morell Date: Fri, 25 Nov 2022 15:34:42 -0600 Subject: [PATCH] Added default number of max workers for Python < 3.5 --- rollbar/lib/thread_pool.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/rollbar/lib/thread_pool.py b/rollbar/lib/thread_pool.py index 6d3408da..8bd7162c 100644 --- a/rollbar/lib/thread_pool.py +++ b/rollbar/lib/thread_pool.py @@ -1,4 +1,6 @@ import logging +import os +import sys from concurrent.futures import ThreadPoolExecutor _pool = None # type: ThreadPoolExecutor|None @@ -10,8 +12,13 @@ def init_pool(max_workers): """ Creates the thread pool with the max workers. - :type max_workers: int + :type max_workers: int|None + :param max_workers: If max_workers is None it will use the logic from the standard library to calculate the number + of threads. However, we ported the logic from Python 3.5 to earlier versions. """ + if max_workers is None and sys.version_info < (3, 5): + max_workers = (os.cpu_count() or 1) * 5 + global _pool _pool = ThreadPoolExecutor(max_workers)