Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion verifiers/envs/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,17 @@ async def generate(
all_states: list[State] = []
try:
for coro in asyncio.as_completed(tasks.keys()):
result = await coro
try:
result = await coro
except Exception:
# cancel all outstanding tasks
for task in tasks.keys():
if not task.done():
task.cancel()
# drain cancellations
await asyncio.gather(*tasks.keys(), return_exceptions=True)
raise

# normalize: independent_scoring returns State, group returns list[State]
states = [result] if independent_scoring else result
all_states.extend(states)
Expand Down
Loading