Skip to content

Commit

Permalink
add: display message when it retries
Browse files Browse the repository at this point in the history
  • Loading branch information
superheavytail committed Mar 28, 2024
1 parent 2f55e70 commit 5998095
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions batched_chatgpt/chatgpt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ def batched_multiprocess_auto_retry(
outputs = [None] * len(items)
c = count()
while not all(outputs):
retry_count = next(c)
if retry_count > 0:
logger.info("There exists failed API call. Retrying...")
# display a warning message if the global retry count exceeds 5.
if retry_count >= 5:
logger.warning("Retry count has exceeds 5. The process may be stuck due to an unresponsive item.")

# printing remained queries if the number of remained queries is small
num_of_remains = outputs.count(None)
print(f"num of remains: {num_of_remains}") if verbose else ...
Expand All @@ -89,10 +96,6 @@ def batched_multiprocess_auto_retry(
pickle_bobj(outputs, pkl_path) if pkl_path else None

time.sleep(sleep_between_chunk) if not all(outputs) else ...

# display a warning message if the global retry count exceeds 5.
if next(c) >= 5:
logger.warning("Retry count has exceeds 5. The process may be stuck due to an unresponsive item.")
return outputs


Expand Down

0 comments on commit 5998095

Please sign in to comment.