Browse Source

user group update add retry

liqian 2 years ago
parent
commit
52653ad8e0
2 changed files with 15 additions and 11 deletions
  1. 4 0
      config.py
  2. 11 11
      user_group_update.py

+ 4 - 0
config.py

@@ -45,6 +45,10 @@ class BaseConfig(object):
         'ad_threshold_auto_update_robot': {
             'webhook': 'https://open.feishu.cn/open-apis/bot/v2/hook/f2494511-18b8-4fa9-8073-91a089dd4bf3',
             'key_word': '广告模型阈值调整'
+        },
+        'ad_user_group_update_robot': {
+            'webhook': 'https://open.feishu.cn/open-apis/bot/v2/hook/d7b29139-0656-4ec6-988e-ef593556795e',
+            'key_word': '用户分组数据更新'
         }
     }
 

+ 11 - 11
user_group_update.py

@@ -96,14 +96,12 @@ def timer_check():
             update_user_group_to_redis(project=project, table=table, dt=dt, app_type_list=app_type_list,
                                        features=features, ad_mid_group_key_params=ad_mid_group_key_params)
             log_.info(f"user group data update end!")
-        # elif now_min > 45:
-        #     log_.info('user group data is None!')
-        #     send_msg_to_feishu(
-        #         webhook=config_.FEISHU_ROBOT['server_robot'].get('webhook'),
-        #         key_word=config_.FEISHU_ROBOT['server_robot'].get('key_word'),
-        #         msg_text=f"rov-offline{config_.ENV_TEXT} - 用户分组数据未准备好!\n"
-        #                  f"traceback: {traceback.format_exc()}"
-        #     )
+            send_msg_to_feishu(
+                webhook=config_.FEISHU_ROBOT['ad_user_group_update_robot'].get('webhook'),
+                key_word=config_.FEISHU_ROBOT['ad_user_group_update_robot'].get('key_word'),
+                msg_text=f"\nrov-offline{config_.ENV_TEXT} - 用户分组数据更新完成\n"
+            )
+
         else:
             # 数据没准备好,1分钟后重新检查
             Timer(60, timer_check).start()
@@ -111,12 +109,14 @@ def timer_check():
     except Exception as e:
         log_.error(f"用户分组数据更新失败, exception: {e}, traceback: {traceback.format_exc()}")
         send_msg_to_feishu(
-            webhook=config_.FEISHU_ROBOT['server_robot'].get('webhook'),
-            key_word=config_.FEISHU_ROBOT['server_robot'].get('key_word'),
-            msg_text=f"rov-offline{config_.ENV_TEXT} - 用户分组数据更新失败\n"
+            webhook=config_.FEISHU_ROBOT['ad_user_group_update_robot'].get('webhook'),
+            key_word=config_.FEISHU_ROBOT['ad_user_group_update_robot'].get('key_word'),
+            msg_text=f"\nrov-offline{config_.ENV_TEXT} - 用户分组数据更新失败\n"
                      f"exception: {e}\n"
                      f"traceback: {traceback.format_exc()}"
         )
+        # 5分钟后重试
+        Timer(1*60, timer_check).start()
 
 
 if __name__ == '__main__':