Check cached API result before Internet

This commit is contained in:
Ivan Kravets
2018-01-13 01:21:53 +02:00
parent 7cad113f0a
commit a6c84da83a
2 changed files with 19 additions and 2 deletions
+4 -1
View File
@@ -621,7 +621,6 @@ def _get_api_result(
def get_api_result(url, params=None, data=None, auth=None, cache_valid=None):
internet_on(raise_exception=True)
from platformio.app import ContentCache
total = 0
max_retries = 5
@@ -634,6 +633,10 @@ def get_api_result(url, params=None, data=None, auth=None, cache_valid=None):
result = cc.get(cache_key)
if result is not None:
return result
# check internet before and resolve issue with 60 seconds timeout
internet_on(raise_exception=True)
result = _get_api_result(url, params, data)
if cache_valid:
with ContentCache() as cc: