Skip to content

Commit

Permalink
loop timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Cheong committed Mar 29, 2023
1 parent 7c8a717 commit e9adec5
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/BingImageCreator.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ def get_images(self, prompt: str) -> list:
polling_url = f"{BING_URL}/images/create/async/results/{request_id}?q={url_encoded_prompt}"
# Poll for results
print("Waiting for results...")
start_wait = time.time()
while True:
if int(time.time() - start_wait) > 300:
raise Exception("Timeout error")
print(".", end="", flush=True)
response = self.session.get(polling_url)
if response.status_code != 200:
Expand Down

0 comments on commit e9adec5

Please sign in to comment.