Browse Source

优化定时任务

peng 1 year ago
parent
commit
95b519f5f0
1 changed files with 1 additions and 4 deletions
  1. 1 4
      Controller/SensorGateway/SmartSwitchController.py

+ 1 - 4
Controller/SensorGateway/SmartSwitchController.py

@@ -367,16 +367,13 @@ class SmartSwitchView(View):
         msg['implementTime'] = now_time
         redis_obj = RedisObject()
         is_lock = redis_obj.CONN.setnx(task_id + 'do_notify', 1)
+        redis_obj.CONN.expire(task_id + 'do_notify', 60)
         if not is_lock:
-            LOGGER.info('定时发送mqtt结果:{},参数:{},{},{},{},{},线程:{},进程:{}'.format(False, serial_number, topic_name, msg,
-                                                                             now_time, task_id,
-                                                                             threading.get_ident(), os.getpid()))
             return
         result = CommonService.req_publish_mqtt_msg(serial_number, topic_name, msg)
         LOGGER.info('定时发送mqtt结果:{},参数:{},{},{},{},{},线程:{},进程:{}'.format(result, serial_number, topic_name, msg,
                                                                          now_time, task_id,
                                                                          threading.get_ident(), os.getpid()))
-        redis_obj.CONN.expire(task_id + 'do_notify', 60)
         redis_obj.del_data(key=task_id + 'do_notify')
 
     @staticmethod