batuergun commited on
Commit
af96b4c
·
1 Parent(s): c57f54f

timeout increased

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -217,25 +217,25 @@ def send_input(user_id):
217
  return response.ok
218
 
219
  def run_fhe(user_id):
220
- """Apply the seizure detection model on the encrypted image previously sent using FHE.
221
-
222
- Args:
223
- user_id (int): The current user's ID.
224
- """
225
- data = {
226
- "user_id": user_id,
227
- }
228
-
229
- # Trigger the FHE execution on the encrypted image previously sent
230
  url = SERVER_URL + "run_fhe"
231
- with requests.post(
232
- url=url,
233
- data=data,
234
- ) as response:
235
- if response.ok:
236
- return response.json()
237
- else:
238
- raise gr.Error("Please wait for the input image to be sent to the server.")
 
 
 
 
 
 
 
 
239
 
240
  def get_output(user_id):
241
  """Retrieve the encrypted output (boolean).
 
217
  return response.ok
218
 
219
  def run_fhe(user_id):
220
+ """Apply the seizure detection model on the encrypted image previously sent using FHE."""
221
+ data = {"user_id": user_id}
 
 
 
 
 
 
 
 
222
  url = SERVER_URL + "run_fhe"
223
+
224
+ try:
225
+ with requests.post(url=url, data=data, timeout=300) as response:
226
+ response.raise_for_status() # Raises an HTTPError for bad responses
227
+ if response.ok:
228
+ return response.json()
229
+ else:
230
+ raise gr.Error(f"Server responded with status code {response.status_code}")
231
+ except requests.exceptions.Timeout:
232
+ raise gr.Error("The request timed out. The server might be overloaded.")
233
+ except requests.exceptions.ConnectionError:
234
+ raise gr.Error("Failed to connect to the server. Please check your network connection.")
235
+ except requests.exceptions.RequestException as e:
236
+ raise gr.Error(f"An error occurred: {str(e)}")
237
+ except Exception as e:
238
+ raise gr.Error(f"An unexpected error occurred: {str(e)}")
239
 
240
  def get_output(user_id):
241
  """Retrieve the encrypted output (boolean).