diff --git a/main.py b/main.py index 98e12745..d8ea82d3 100644 --- a/main.py +++ b/main.py @@ -20,7 +20,8 @@ def get_weather(): url = "http://autodev.openspeech.cn/csp/api/v2.1/weather?openId=aiuicus&clientType=android&sign=android&city=" + city - res = requests.get(url).json() + # Warning: The 'requests.get' method does not use any 'timeout' threshold which may cause program to hang indefinitely. + res = requests.get(url, timeout=0.4).json() weather = res['data']['list'][0] return weather['weather'], math.floor(weather['temp'])