Skip to content

Commit

Permalink
Move sleep
Browse files Browse the repository at this point in the history
Signed-off-by: harupy <hkawamura0130@gmail.com>
  • Loading branch information
harupy committed Apr 28, 2023
1 parent 8691503 commit 51c26a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
3 changes: 2 additions & 1 deletion mlflow/langchain/api_request_parallel_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ def process_api_requests(
requests_iter = enumerate(requests)
with ThreadPoolExecutor(max_workers=max_workers) as executor:
while True:
time.sleep(0.001)
# get next request (if one is not already waiting for capacity)
if next_request is None:
if not retry_queue.empty():
Expand Down Expand Up @@ -134,6 +133,8 @@ def process_api_requests(
if status_tracker.num_tasks_in_progress == 0:
break

time.sleep(0.001) # avoid busy waiting

# after finishing, log final status
if status_tracker.num_tasks_failed > 0:
raise mlflow.MlflowException(
Expand Down
3 changes: 2 additions & 1 deletion mlflow/openai/api_request_parallel_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def process_api_requests(
requests_exhausted = False
with ThreadPoolExecutor(max_workers=max_workers) as executor:
while True:
time.sleep(0.001)
# get next request (if one is not already waiting for capacity)
if next_request is None:
if not retry_queue.empty():
Expand Down Expand Up @@ -287,6 +286,8 @@ def process_api_requests(
time.sleep(remaining_seconds_to_pause)
# ^e.g., if pause is 15 seconds and final limit was hit 5 seconds ago

time.sleep(0.001) # avoid busy waiting

# after finishing, log final status
if status_tracker.num_tasks_failed > 0:
raise mlflow.MlflowException(
Expand Down

0 comments on commit 51c26a9

Please sign in to comment.