Skip to content

Commit

Permalink
timeout issue with requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Abid committed Mar 2, 2021
1 parent c0a3b92 commit a62ab73
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion gradio.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: gradio
Version: 1.6.1
Version: 1.6.2
Summary: Python library for easily interacting with trained machine learning models
Home-page: https://github.com/gradio-app/gradio-UI
Author: Abubakar Abid
Expand Down
6 changes: 3 additions & 3 deletions gradio/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def get_output_instance(iface):
if self.analytics_enabled:
try:
requests.post(analytics_url + 'gradio-initiated-analytics/',
data=data)
data=data, timeout=2)
except requests.ConnectionError:
pass # do not push analytics if no network

Expand Down Expand Up @@ -498,7 +498,7 @@ def send_error_analytics(analytics_enabled):
if analytics_enabled:
try:
requests.post(analytics_url + 'gradio-error-analytics/',
data=data)
data=data, timeout=2)
except requests.ConnectionError:
pass # do not push analytics if no network

Expand All @@ -514,7 +514,7 @@ def send_launch_analytics(analytics_enabled, inbrowser, is_colab, share, share_u
}
try:
requests.post(analytics_url + 'gradio-launched-analytics/',
data=data)
data=data, timeout=2)
except requests.ConnectionError:
pass # do not push analytics if no network

Expand Down
6 changes: 3 additions & 3 deletions gradio/networking.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@

def get_local_ip_address():
try:
ip_address = requests.get('https://api.ipify.org').text
ip_address = requests.get('https://api.ipify.org', timeout=2).text
except requests.ConnectionError:
ip_address = "No internet connection"
return ip_address
Expand Down Expand Up @@ -145,7 +145,7 @@ def log_feature_analytics(feature):
requests.post(GRADIO_FEATURE_ANALYTICS_URL,
data={
'ip_address': IP_ADDRESS,
'feature': feature})
'feature': feature}, timeout=2)
except requests.ConnectionError:
pass # do not push analytics if no network

Expand Down Expand Up @@ -322,7 +322,7 @@ def url_ok(url):
try:
for _ in range(5):
time.sleep(.500)
r = requests.head(url)
r = requests.head(url, timeout=2)
if r.status_code == 200:
return True
except (ConnectionError, requests.exceptions.ConnectionError):
Expand Down
2 changes: 1 addition & 1 deletion gradio/strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
}

try:
updated_messaging = requests.get(MESSAGING_API_ENDPOINT).json()
updated_messaging = requests.get(MESSAGING_API_ENDPOINT, timeout=2).json()
en.update(updated_messaging)
except (requests.ConnectionError, json.decoder.JSONDecodeError): # Use default messaging
pass
4 changes: 2 additions & 2 deletions gradio/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def error_analytics(type):
data = {'error': '{} in launch method'.format(type)}
try:
requests.post(analytics_url + 'gradio-error-analytics/',
data=data)
data=data, timeout=2)
except requests.ConnectionError:
pass # do not push analytics if no network

Expand Down Expand Up @@ -63,7 +63,7 @@ def ipython_check():

def readme_to_html(article):
try:
response = requests.get(article)
response = requests.get(article, timeout=2)
if response.status_code == requests.codes.ok:
article = response.text
except requests.exceptions.RequestException:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='gradio',
version='1.6.1',
version='1.6.2',
include_package_data=True,
description='Python library for easily interacting with trained machine learning models',
author='Abubakar Abid',
Expand Down

0 comments on commit a62ab73

Please sign in to comment.