Skip to content

Commit

Permalink
testing multiprocessing with 10 contexts
Browse files Browse the repository at this point in the history
  • Loading branch information
star-nox committed Dec 11, 2023
1 parent 9e6d9ae commit 01c9eff
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions ai_ta_backend/filtering_contexts.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor
from functools import partial
from multiprocessing import Manager
from multiprocessing import Pool, Manager


from ai_ta_backend.utils_tokenization import count_tokens_and_cost
Expand All @@ -41,10 +41,10 @@ def run_context_filtering(contexts, user_query, max_time_before_return=45, max_c
partial_func2 = partial(select_context, result=filtered_contexts)

with ProcessPoolExecutor(max_workers=200) as executor1:
results1 = list(executor1.map(partial_func1, contexts))
results1 = list(executor1.map(partial_func1, contexts[:10]))

print(f"⏰ ThreadPool runtime: {(time.monotonic() - start_time):.2f} seconds")

with ProcessPoolExecutor(max_workers=200) as executor:
executor.map(partial_func2, results1)

Expand Down

0 comments on commit 01c9eff

Please sign in to comment.