peng пре 1 година
родитељ
комит
f66b91e933
1 измењених фајлова са 4 додато и 2 уклоњено
  1. 4 2
      Controller/WeatherControl.py

+ 4 - 2
Controller/WeatherControl.py

@@ -69,8 +69,10 @@ class WeatherView(View):
                     humidity = weather_list[0]['humidity']
                     for item in weather_list:
                         temp_time = CommonService.str_to_timestamp(item['date'] + ' ' + item['hour'] + ':00:00')
-                        redis_obj.set_ex_data('city_id_{}_{}_weather'.format(city_id, temp_time),
-                                              '{}/{}'.format(item['temp'], item['humidity']), 86400)
+                        result = redis_obj.set_ex_data('city_id_{}_{}_weather'.format(city_id, temp_time),
+                                                       '{}/{}'.format(item['temp'], item['humidity']), 86400)
+                        if not result:
+                            LOGGER.info('写入天气失败:{}'.format(item))
             if not all([temp, humidity]):
                 return response.json(10, '获取天气失败')
             return response.json(0, {'temp': temp, 'humidity': humidity})