mirror of
https://github.com/gradio-app/gradio.git
synced 2024-12-27 02:30:17 +08:00
read timeout handling
This commit is contained in:
parent
b2b3eab84d
commit
401a499ef7
@ -183,8 +183,8 @@ class Interface:
|
||||
if self.analytics_enabled:
|
||||
try:
|
||||
requests.post(analytics_url + 'gradio-initiated-analytics/',
|
||||
data=data, timeout=2)
|
||||
except requests.ConnectionError:
|
||||
data=data, timeout=3)
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
pass # do not push analytics if no network
|
||||
|
||||
def get_config_file(self):
|
||||
@ -498,8 +498,8 @@ def send_error_analytics(analytics_enabled):
|
||||
if analytics_enabled:
|
||||
try:
|
||||
requests.post(analytics_url + 'gradio-error-analytics/',
|
||||
data=data, timeout=2)
|
||||
except requests.ConnectionError:
|
||||
data=data, timeout=3)
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
pass # do not push analytics if no network
|
||||
|
||||
def send_launch_analytics(analytics_enabled, inbrowser, is_colab, share, share_url):
|
||||
@ -514,8 +514,8 @@ def send_launch_analytics(analytics_enabled, inbrowser, is_colab, share, share_u
|
||||
}
|
||||
try:
|
||||
requests.post(analytics_url + 'gradio-launched-analytics/',
|
||||
data=data, timeout=2)
|
||||
except requests.ConnectionError:
|
||||
data=data, timeout=3)
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
pass # do not push analytics if no network
|
||||
|
||||
|
||||
|
@ -51,8 +51,8 @@ cli.show_server_banner = lambda *x: None
|
||||
|
||||
def get_local_ip_address():
|
||||
try:
|
||||
ip_address = requests.get('https://api.ipify.org', timeout=2).text
|
||||
except requests.ConnectionError:
|
||||
ip_address = requests.get('https://api.ipify.org', timeout=3).text
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
ip_address = "No internet connection"
|
||||
return ip_address
|
||||
|
||||
@ -145,8 +145,8 @@ def log_feature_analytics(feature):
|
||||
requests.post(GRADIO_FEATURE_ANALYTICS_URL,
|
||||
data={
|
||||
'ip_address': IP_ADDRESS,
|
||||
'feature': feature}, timeout=2)
|
||||
except requests.ConnectionError:
|
||||
'feature': feature}, timeout=3)
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
pass # do not push analytics if no network
|
||||
|
||||
@app.route("/api/score_similarity/", methods=["POST"])
|
||||
@ -322,7 +322,7 @@ def url_ok(url):
|
||||
try:
|
||||
for _ in range(5):
|
||||
time.sleep(.500)
|
||||
r = requests.head(url, timeout=2)
|
||||
r = requests.head(url, timeout=3)
|
||||
if r.status_code == 200:
|
||||
return True
|
||||
except (ConnectionError, requests.exceptions.ConnectionError):
|
||||
|
@ -28,7 +28,7 @@ en = {
|
||||
}
|
||||
|
||||
try:
|
||||
updated_messaging = requests.get(MESSAGING_API_ENDPOINT, timeout=2).json()
|
||||
updated_messaging = requests.get(MESSAGING_API_ENDPOINT, timeout=3).json()
|
||||
en.update(updated_messaging)
|
||||
except (requests.ConnectionError, json.decoder.JSONDecodeError): # Use default messaging
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout, json.decoder.JSONDecodeError): # Use default messaging
|
||||
pass
|
||||
|
@ -28,8 +28,8 @@ def error_analytics(type):
|
||||
data = {'error': '{} in launch method'.format(type)}
|
||||
try:
|
||||
requests.post(analytics_url + 'gradio-error-analytics/',
|
||||
data=data, timeout=2)
|
||||
except requests.ConnectionError:
|
||||
data=data, timeout=3)
|
||||
except (requests.ConnectionError, requests.exceptions.ReadTimeout):
|
||||
pass # do not push analytics if no network
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ def ipython_check():
|
||||
|
||||
def readme_to_html(article):
|
||||
try:
|
||||
response = requests.get(article, timeout=2)
|
||||
response = requests.get(article, timeout=3)
|
||||
if response.status_code == requests.codes.ok:
|
||||
article = response.text
|
||||
except requests.exceptions.RequestException:
|
||||
|
Loading…
Reference in New Issue
Block a user