feat: 重构任务处理逻辑以简化并发执行和结果处理
This commit is contained in:
parent
2c4477aa51
commit
2f5febf7fb
34
main.py
34
main.py
@ -358,21 +358,27 @@ def integrate_data_parallel():
|
|||||||
if not tasks:
|
if not tasks:
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
continue
|
continue
|
||||||
|
for payload, kitem in tasks:
|
||||||
|
proxname = proxiesdict.get(kitem['rn'])
|
||||||
|
print(proxname)
|
||||||
|
h = gettoken(proxname)
|
||||||
|
print(h)
|
||||||
|
get_searchInfo(kitem['keyword'], kitem['level'], h, proxiesdict)
|
||||||
|
|
||||||
futures = [
|
# futures = [
|
||||||
executor.submit(search_worker, payload, kitem, flag)
|
# executor.submit(search_worker, payload, kitem, flag)
|
||||||
for payload, kitem in tasks
|
# for payload, kitem in tasks
|
||||||
]
|
# ]
|
||||||
|
#
|
||||||
# 统计回滚
|
# # 统计回滚
|
||||||
rollback = {0: [], 1: [], 2: []}
|
# rollback = {0: [], 1: [], 2: []}
|
||||||
|
#
|
||||||
for fut in concurrent.futures.as_completed(futures):
|
# for fut in concurrent.futures.as_completed(futures):
|
||||||
ok, f_flag, payload, kitem, v_list = fut.result()
|
# ok, f_flag, payload, kitem, v_list = fut.result()
|
||||||
|
#
|
||||||
if not ok:
|
# if not ok:
|
||||||
rollback[f_flag].append(payload)
|
# rollback[f_flag].append(payload)
|
||||||
continue
|
# continue
|
||||||
|
|
||||||
for item in v_list:
|
for item in v_list:
|
||||||
if not v_list:
|
if not v_list:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user