Skip to content

Commit 195a165

Browse files
authored
fix: await futures
Await futures in progress checker
2 parents 8ffe6d3 + afc1f87 commit 195a165

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

bigcodebench/evaluate.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import threading
77
import time
88
from collections import Counter, defaultdict
9-
from concurrent.futures import ProcessPoolExecutor, as_completed
9+
from concurrent.futures import ProcessPoolExecutor, as_completed, wait, FIRST_COMPLETED
1010
from datetime import datetime
1111
from typing import Any, Dict, List, Tuple
1212
from warnings import warn
@@ -204,14 +204,13 @@ def evaluate(flags):
204204
assert len(completion_id) == len(problems), "Missing problems in samples"
205205

206206
def stucking_checker():
207-
while remainings:
208-
last_size = len(remainings)
209-
time.sleep(240)
210-
if last_size != len(remainings) or len(remainings) == 0:
211-
continue
212-
# Potential stucking
213-
warn("No samples had finished testing in the last 240s")
214-
warn(f"{len(remainings)} samples to be tested: {remainings}")
207+
not_done = futures
208+
while len(not_done) > 0:
209+
done, not_done = wait(not_done, timeout=240, return_when=FIRST_COMPLETED)
210+
211+
if len(done) == 0:
212+
warn("No samples have finished testing in the last 240s")
213+
warn(f"{len(remainings)} samples to be tested: {remainings}")
215214

216215
threading.Thread(target=stucking_checker).start()
217216

0 commit comments

Comments
 (0)