Skip to content

Commit

Permalink
quickfix: don't sleep on the last iteration of batch_add (#124)
Browse files Browse the repository at this point in the history
* don't sleep on last iteration
  • Loading branch information
jerpint authored Aug 17, 2023
1 parent 24acaac commit ecda6d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions buster/documents_manager/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,14 @@ def batch_add(
)

elapsed_time = time.time() - start_time
sleep_time = max(0, min_time_interval - elapsed_time)

# Sleep to ensure the minimum time interval is maintained
if sleep_time > 0:
logger.info(f"Sleeping for {round(sleep_time)} seconds...")
time.sleep(sleep_time)
# Only sleep if it's not the last iteration
if batch_idx < total_batches - 1:
sleep_time = max(0, min_time_interval - elapsed_time)
if sleep_time > 0:
logger.info(f"Sleeping for {round(sleep_time)} seconds...")
time.sleep(sleep_time)

logger.info("All batches processed.")

Expand Down

0 comments on commit ecda6d8

Please sign in to comment.