Pendrokar commited on
Commit
3980780
β€’
1 Parent(s): b8a1b21

catch web exceptions

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -26,8 +26,12 @@ def run_xvaserver():
26
 
27
  # contact local xVASynth server; ~2 second timeout
28
  print('Attempting to connect to xVASynth...')
29
- response = requests.get('http://0.0.0.0:8008')
30
- response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
 
 
 
 
31
 
32
  print('xVAServer running on port 8008')
33
 
@@ -93,8 +97,12 @@ def predict(input, pacing):
93
  'useSR': use_sr,
94
  'useCleanup': use_cleanup,
95
  }
96
- response = requests.post('http://0.0.0.0:8008/synthesize', json=data)
97
- # response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
 
 
 
 
98
 
99
  print('server.log contents:')
100
  with open('server.log', 'r') as f:
 
26
 
27
  # contact local xVASynth server; ~2 second timeout
28
  print('Attempting to connect to xVASynth...')
29
+ try:
30
+ response = requests.get('http://0.0.0.0:8008')
31
+ response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
32
+ except requests.exceptions.RequestException as err:
33
+ print('Failed to connect!')
34
+ return
35
 
36
  print('xVAServer running on port 8008')
37
 
 
97
  'useSR': use_sr,
98
  'useCleanup': use_cleanup,
99
  }
100
+
101
+ try:
102
+ response = requests.post('http://0.0.0.0:8008/synthesize', json=data)
103
+ response.raise_for_status() # If the response contains an HTTP error status code, raise an exception
104
+ except requests.exceptions.RequestException as err:
105
+ print('Failed to synthesize!')
106
 
107
  print('server.log contents:')
108
  with open('server.log', 'r') as f: