Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

limit the threads to the number of CPUs #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion findatapy/market/marketdatagenerator.py
Expand Up @@ -319,6 +319,10 @@ def fetch_group_time_series(self, market_data_request_list):
thread_no = DataConstants().market_thread_no[market_data_request_list[0].data_source]

if thread_no > 0:
# limit the threads to the number of available CPUs
from multiprocessing import cpu_count
thread_no = min(cpu_count(),thread_no)

pool = Pool(thread_no)

# open the market data downloads in their own threads and return the results
Expand Down Expand Up @@ -417,4 +421,4 @@ def create_category_key(self, market_data_request, ticker=None):
return key

def create_cache_file_name(self, filename):
return DataConstants().folder_time_series_data + "/" + filename
return DataConstants().folder_time_series_data + "/" + filename