Skip to content

Commit

Permalink
Added default number of max workers for Python < 3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
danielmorell committed Nov 25, 2022
1 parent f4043fe commit e14af00
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion rollbar/lib/thread_pool.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import os
import sys
from concurrent.futures import ThreadPoolExecutor

_pool = None # type: ThreadPoolExecutor|None
Expand All @@ -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)

Expand Down

0 comments on commit e14af00

Please sign in to comment.