|
@@ -5,6 +5,7 @@
|
|
# @Software: PyCharm
|
|
# @Software: PyCharm
|
|
|
|
|
|
import time
|
|
import time
|
|
|
|
+import multiprocessing
|
|
import os
|
|
import os
|
|
import gevent
|
|
import gevent
|
|
import datetime
|
|
import datetime
|
|
@@ -209,7 +210,7 @@ def process_with_region(region, df_merged, app_type, data_key, rule_key, rule_pa
|
|
|
|
|
|
|
|
|
|
def process_with_app_type(app_type, params, region_code_list, feature_df, now_date, now_h):
|
|
def process_with_app_type(app_type, params, region_code_list, feature_df, now_date, now_h):
|
|
- log_.info(f"app_type = {app_type}")
|
|
|
|
|
|
+ log_.info(f"app_type = {app_type} start...")
|
|
data_params_item = params.get('data_params')
|
|
data_params_item = params.get('data_params')
|
|
rule_params_item = params.get('rule_params')
|
|
rule_params_item = params.get('rule_params')
|
|
for param in params.get('params_list'):
|
|
for param in params.get('params_list'):
|
|
@@ -228,6 +229,7 @@ def process_with_app_type(app_type, params, region_code_list, feature_df, now_da
|
|
for region in region_code_list
|
|
for region in region_code_list
|
|
]
|
|
]
|
|
gevent.joinall(task_list)
|
|
gevent.joinall(task_list)
|
|
|
|
+ log_.info(f"app_type = {app_type} end!")
|
|
|
|
|
|
|
|
|
|
def rank_by_24h(project, table, now_date, now_h, rule_params, region_code_list):
|
|
def rank_by_24h(project, table, now_date, now_h, rule_params, region_code_list):
|
|
@@ -241,6 +243,27 @@ def rank_by_24h(project, table, now_date, now_h, rule_params, region_code_list):
|
|
# ]
|
|
# ]
|
|
# gevent.joinall(t)
|
|
# gevent.joinall(t)
|
|
|
|
|
|
|
|
+ """
|
|
|
|
+ ps = []
|
|
|
|
+ for app_type, params in rule_params.items():
|
|
|
|
+ p = multiprocessing.Process(target=process_with_app_type,
|
|
|
|
+ args=(app_type, params, region_code_list, feature_df, now_date, now_h))
|
|
|
|
+ ps.append(p)
|
|
|
|
+ for p in ps:
|
|
|
|
+ p.daemon = True
|
|
|
|
+ p.start()
|
|
|
|
+ for p in ps:
|
|
|
|
+ p.join()
|
|
|
|
+ """
|
|
|
|
+
|
|
|
|
+ pool = multiprocessing.Pool(processes=len(config_.APP_TYPE))
|
|
|
|
+ for app_type, params in rule_params.items():
|
|
|
|
+ pool.apply_async(func=process_with_app_type,
|
|
|
|
+ args=(app_type, params, region_code_list, feature_df, now_date, now_h))
|
|
|
|
+ pool.close()
|
|
|
|
+ pool.join()
|
|
|
|
+
|
|
|
|
+ """
|
|
for app_type, params in rule_params.items():
|
|
for app_type, params in rule_params.items():
|
|
log_.info(f"app_type = {app_type} start...")
|
|
log_.info(f"app_type = {app_type} start...")
|
|
data_params_item = params.get('data_params')
|
|
data_params_item = params.get('data_params')
|
|
@@ -273,7 +296,7 @@ def rank_by_24h(project, table, now_date, now_h, rule_params, region_code_list):
|
|
t.join()
|
|
t.join()
|
|
log_.info(f"param = {param} end!")
|
|
log_.info(f"param = {param} end!")
|
|
log_.info(f"app_type = {app_type} end!")
|
|
log_.info(f"app_type = {app_type} end!")
|
|
-
|
|
|
|
|
|
+ """
|
|
|
|
|
|
# for app_type, params in rule_params.items():
|
|
# for app_type, params in rule_params.items():
|
|
# log_.info(f"app_type = {app_type}")
|
|
# log_.info(f"app_type = {app_type}")
|