Skip to content

Commit

Permalink
[eval] use mp Pool instead ProcessPoolExecutor (#4025)
Browse files Browse the repository at this point in the history
  • Loading branch information
xingyaoww committed Sep 24, 2024
1 parent 582f07f commit a66e738
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions evaluation/utils/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import subprocess
import time
import traceback
from concurrent.futures import ProcessPoolExecutor, as_completed
from typing import Any, Awaitable, Callable, TextIO

import pandas as pd
Expand Down Expand Up @@ -328,21 +327,22 @@ def run_evaluation(

try:
if use_multiprocessing:
with ProcessPoolExecutor(num_workers) as executor:
futures = [
executor.submit(
with mp.Pool(num_workers) as pool:
results = [
pool.apply_async(
_process_instance_wrapper,
process_instance_func=process_instance_func,
instance=instance,
metadata=metadata,
use_mp=True,
max_retries=max_retries,
args=(
process_instance_func,
instance,
metadata,
True,
max_retries,
),
)
for _, instance in dataset.iterrows()
]
for future in as_completed(futures):
result = future.result()
update_progress(result, pbar, output_fp)
for result in results:
update_progress(result.get(), pbar, output_fp)
else:
for _, instance in dataset.iterrows():
result = _process_instance_wrapper(
Expand Down

0 comments on commit a66e738

Please sign in to comment.