Skip to content

Commit e14af00

Browse files
committed
Added default number of max workers for Python < 3.5
1 parent f4043fe commit e14af00

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

rollbar/lib/thread_pool.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import logging
2+
import os
3+
import sys
24
from concurrent.futures import ThreadPoolExecutor
35

46
_pool = None # type: ThreadPoolExecutor|None
@@ -10,8 +12,13 @@ def init_pool(max_workers):
1012
"""
1113
Creates the thread pool with the max workers.
1214
13-
:type max_workers: int
15+
:type max_workers: int|None
16+
:param max_workers: If max_workers is None it will use the logic from the standard library to calculate the number
17+
of threads. However, we ported the logic from Python 3.5 to earlier versions.
1418
"""
19+
if max_workers is None and sys.version_info < (3, 5):
20+
max_workers = (os.cpu_count() or 1) * 5
21+
1522
global _pool
1623
_pool = ThreadPoolExecutor(max_workers)
1724

0 commit comments

Comments
 (0)