Browse Source

线程池异步推送图片

locky 1 year ago
parent
commit
af4ddbbc91
1 changed files with 9 additions and 2 deletions
  1. 9 2
      Service/DevicePushService.py

+ 9 - 2
Service/DevicePushService.py

@@ -400,11 +400,18 @@ class DevicePushService:
                 else:
                 else:
                     key = '{}/{}/{}_0.jpeg'.format(kwargs['uid'], kwargs['channel'], kwargs['n_time'])
                     key = '{}/{}/{}_0.jpeg'.format(kwargs['uid'], kwargs['channel'], kwargs['n_time'])
                 # 开始异步推送图片
                 # 开始异步推送图片
-                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,
                     push_type, kwargs['aws_s3_client'], kwargs['bucket'], key,
                     kwargs['uid'], kwargs['appBundleId'], kwargs['token_val'], kwargs['event_type'], kwargs['n_time'],
                     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_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
                 push_result = True
 
 
             # 不推图
             # 不推图