Skip to content

Commit 50ee9e7

Browse files
committed
avoid sequentially process the retried entries. do parallel async
1 parent 232dab5 commit 50ee9e7

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/bespokelabs/curator/request_processor/base_online_request_processor.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ async def process_requests_from_file(
329329
await asyncio.gather(*pending_requests)
330330

331331
# Process any remaining retries in the queue
332+
pending_retries = []
332333
while not queue_of_requests_to_retry.empty():
333334
retry_request = await queue_of_requests_to_retry.get()
334335
token_estimate = self.estimate_total_tokens(retry_request.generic_request.messages)
@@ -356,7 +357,12 @@ async def process_requests_from_file(
356357
status_tracker=status_tracker,
357358
)
358359
)
359-
await task
360+
pending_retries.append(task)
361+
await asyncio.sleep(0.1) # Allow other tasks to run
362+
363+
# Wait for all retry tasks to complete
364+
if pending_retries:
365+
await asyncio.gather(*pending_retries)
360366

361367
status_tracker.pbar.close()
362368

@@ -406,7 +412,7 @@ async def handle_single_request_with_retries(
406412

407413
except Exception as e:
408414
logger.warning(
409-
f"Request {request.task_id} failed with Exception {e}, attempts left {request.attempts_left-1}"
415+
f"Request {request.task_id} failed with Exception {e}, attempts left {request.attempts_left}"
410416
)
411417
status_tracker.num_other_errors += 1
412418
request.result.append(e)

0 commit comments

Comments
 (0)