Spaces:
Sleeping
Sleeping
Dmitry Trifonov
commited on
Commit
·
5fff7ad
1
Parent(s):
5a60604
fix timeout when waiting for stable diffusion server
Browse files
fair.py
CHANGED
@@ -149,11 +149,12 @@ def wait_for_server(retries, timeout, delay=1.0):
|
|
149 |
r = requests.get(ENDPOINT_ADDRESS, timeout=timeout)
|
150 |
r.raise_for_status()
|
151 |
return
|
152 |
-
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError, requests.exceptions.Timeout):
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
|
|
157 |
|
158 |
|
159 |
def start_server():
|
@@ -186,7 +187,7 @@ def start_server():
|
|
186 |
|
187 |
def text_to_image(text):
|
188 |
try:
|
189 |
-
wait_for_server(retries=1, timeout=0
|
190 |
except ServerNotReadyException:
|
191 |
start_server()
|
192 |
|
|
|
149 |
r = requests.get(ENDPOINT_ADDRESS, timeout=timeout)
|
150 |
r.raise_for_status()
|
151 |
return
|
152 |
+
except (requests.exceptions.ConnectionError, requests.exceptions.HTTPError, requests.exceptions.Timeout) as e:
|
153 |
+
if i == retries - 1:
|
154 |
+
raise ServerNotReadyException("Failed to start the server") from e
|
155 |
+
else:
|
156 |
+
logger.info("Server is not ready yet")
|
157 |
+
time.sleep(delay)
|
158 |
|
159 |
|
160 |
def start_server():
|
|
|
187 |
|
188 |
def text_to_image(text):
|
189 |
try:
|
190 |
+
wait_for_server(retries=1, timeout=1.0, delay=0.0)
|
191 |
except ServerNotReadyException:
|
192 |
start_server()
|
193 |
|