Sfoglia il codice sorgente

注释线程池,还原线程

locky 1 anno fa
parent
commit
e43b73f678
2 ha cambiato i file con 26 aggiunte e 26 eliminazioni
  1. 12 12
      Controller/DetectControllerV2.py
  2. 14 14
      Service/DevicePushService.py

+ 12 - 12
Controller/DetectControllerV2.py

@@ -133,14 +133,14 @@ class NotificationV2View(View):
                       'uid_set_push_list': uid_set_push_list}
 
             # 使用全局的线程池提交推送任务
-            thread_pool = GlobalThreadPool()
-            thread_pool.submit(push_and_save_data, **params)
+            # thread_pool = GlobalThreadPool()
+            # thread_pool.submit(push_and_save_data, **params)
 
             # 异步推送消息和保存数据
-            # push_thread = threading.Thread(
-            #     target=push_and_save_data,
-            #     kwargs=params)
-            # push_thread.start()
+            push_thread = threading.Thread(
+                target=push_and_save_data,
+                kwargs=params)
+            push_thread.start()
 
             # 视频通话不返回图片链接
             if event_type == 607:
@@ -177,14 +177,14 @@ def push_and_save_data(**params):
     TIME_LOGGER.info('{}开始异步存表和推送'.format(uid))
 
     # 线程池推送消息
-    thread_pool = GlobalThreadPool()
-    thread_pool.submit(DevicePushService.push_msg, **params)
+    # thread_pool = GlobalThreadPool()
+    # thread_pool.submit(DevicePushService.push_msg, **params)
 
     # 异步推送消息
-    # push_thread = threading.Thread(
-    #     target=DevicePushService.push_msg,
-    #     kwargs=params)
-    # push_thread.start()
+    push_thread = threading.Thread(
+        target=DevicePushService.push_msg,
+        kwargs=params)
+    push_thread.start()
     # 保存推送数据
     result = DevicePushService.save_msg_push(**params)
     TIME_LOGGER.info('{}存表结果:{}'.format(uid, result))

+ 14 - 14
Service/DevicePushService.py

@@ -214,12 +214,12 @@ class DevicePushService:
                     params['push_type'] = push_type
                     params['redis_obj'] = redis_obj
 
-                    GlobalThreadPool().submit(cls.send_app_msg_push, **params)
-                    # push_thread = threading.Thread(
-                    #     target=cls.send_app_msg_push,
-                    #     kwargs=params
-                    # )
-                    # push_thread.start()
+                    # GlobalThreadPool().submit(cls.send_app_msg_push, **params)
+                    push_thread = threading.Thread(
+                        target=cls.send_app_msg_push,
+                        kwargs=params
+                    )
+                    push_thread.start()
         except Exception as e:
             ERROR_INFO_LOGGER.info(
                 '推送消息线程异常,uid:{},error_line:{},error_msg:{}'
@@ -396,17 +396,17 @@ class DevicePushService:
                 else:
                     key = '{}/{}/{}_0.jpeg'.format(kwargs['uid'], kwargs['channel'], kwargs['n_time'])
                 # 开始异步推送图片
-                thread_pool = GlobalThreadPool()
-                thread_pool.submit(cls.async_send_picture_push, (
-                    push_type, kwargs['aws_s3_client'], kwargs['bucket'], key,
-                    kwargs['uid'], kwargs['appBundleId'], kwargs['token_val'], kwargs['event_type'], kwargs['n_time'],
-                    push_kwargs['msg_title'], push_kwargs['msg_text'], kwargs['channel'], kwargs['storage_location']))
-
-                # push_thread = threading.Thread(target=cls.async_send_picture_push, args=(
+                # thread_pool = GlobalThreadPool()
+                # thread_pool.submit(cls.async_send_picture_push, (
                 #     push_type, kwargs['aws_s3_client'], kwargs['bucket'], key,
                 #     kwargs['uid'], kwargs['appBundleId'], kwargs['token_val'], kwargs['event_type'], kwargs['n_time'],
                 #     push_kwargs['msg_title'], push_kwargs['msg_text'], kwargs['channel'], kwargs['storage_location']))
-                # push_thread.start()
+
+                push_thread = threading.Thread(target=cls.async_send_picture_push, args=(
+                    push_type, kwargs['aws_s3_client'], kwargs['bucket'], key,
+                    kwargs['uid'], kwargs['appBundleId'], kwargs['token_val'], kwargs['event_type'], kwargs['n_time'],
+                    push_kwargs['msg_title'], push_kwargs['msg_text'], kwargs['channel'], kwargs['storage_location']))
+                push_thread.start()
 
                 push_result = True