Use multiprocessing.cpu_count for max suggestion workers

celinanperalta/daemon
Celina Peralta 2023-02-04 12:09:14 -05:00
parent ce57c1f3ec
commit a6c6ffa49a
2 changed files with 3 additions and 5 deletions

View File

@ -3,8 +3,8 @@ COLLECTION_IMPORT_LIMIT = 10
ITEMS_PER_IMPORT_THREAD = 25
# Max thread count for data ingest
IO_MAX_WORKERS = 10
NGRAMS_MAX_WORKERS = 10
# Size of list of items to process into ngrams per process
NGRAMS_PER_PROCESS = 25

View File

@ -2,7 +2,7 @@ import concurrent.futures
import os
import queue
import time
from multiprocessing import Manager
from multiprocessing import Manager, cpu_count
from threading import get_ident
import config
@ -96,9 +96,7 @@ def run():
db_pool = concurrent.futures.ThreadPoolExecutor()
io_pool = concurrent.futures.ThreadPoolExecutor(max_workers=config.IO_MAX_WORKERS)
ngrams_pool = concurrent.futures.ProcessPoolExecutor(
max_workers=config.NGRAMS_MAX_WORKERS
)
ngrams_pool = concurrent.futures.ProcessPoolExecutor(max_workers=cpu_count())
def shutdown():
print("Stopping import.")