Skip to content

Commit bf58e0f

Browse files
committed
Wait on futures in progress checker
1 parent ad3e087 commit bf58e0f

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

bigcodebench/evaluate.py

Lines changed: 6 additions & 18 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, ALL_COMPLETED
1010
from datetime import datetime
1111
from typing import Any, Dict, List, Tuple
1212
from warnings import warn
@@ -204,26 +204,14 @@ def evaluate(flags):
204204
assert len(completion_id) == len(problems), "Missing problems in samples"
205205

206206
def stucking_checker():
207-
unchanged_duration = 0
208-
last_size = len(remainings)
209-
210-
while remainings:
211-
time.sleep(1)
212-
current_size = len(remainings)
213-
214-
if current_size != last_size or current_size == 0:
215-
# Reset the unchanged duration if something has changed
216-
unchanged_duration = 0
217-
last_size = current_size
218-
else:
219-
# Increment the duration if nothing has changed
220-
unchanged_duration += 1
221-
222-
if unchanged_duration >= 240:
207+
not_done = [True]
208+
while len(not_done) > 0:
209+
done, not_done = wait(futures, timeout=240, return_when=ALL_COMPLETED)
210+
211+
if len(done) == 0:
223212
# Output warnings after 240 seconds of no change
224213
warn("No samples have finished testing in the last 240s")
225214
warn(f"{len(remainings)} samples to be tested: {remainings}")
226-
unchanged_duration = 0 # Reset after warning
227215

228216
threading.Thread(target=stucking_checker).start()
229217

0 commit comments

Comments
 (0)