File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -146,16 +146,20 @@ def limit_concurrency_sync(sample):
146146 tasks = [asyncio .ensure_future (loop .run_in_executor (executor , partial (limit_concurrency_sync , sample ))) for
147147 sample in data ]
148148
149- done , pending = await asyncio .wait (tasks , return_when = asyncio .FIRST_EXCEPTION )
150149 status = ExperimentStatus .COMPLETED
151- for task in done :
150+ with tqdm ( total = len ( tasks ), desc = "Running samples" , unit = "sample" ) as pbar :
152151 try :
153- await task
154- except Exception as e :
155- print (f"Experiment stopped due to an error: { str (e )} " )
156- for _p in pending :
157- _p .cancel ()
158- status = ExperimentStatus .FAILED
152+ for coro in asyncio .as_completed (tasks ):
153+ try :
154+ await coro
155+ pbar .update (1 )
156+ except Exception as e :
157+ print (f"\n Experiment stopped due to an error: { str (e )} \n " )
158+ status = ExperimentStatus .FAILED
159+ for task in tasks :
160+ task .cancel ()
161+ except asyncio .CancelledError :
162+ pass
159163
160164 await asyncio .sleep (0.2 )
161165 total_evals = len (thread_ids_running_evals .get ())
You can’t perform that action at this time.
0 commit comments