提交 3278b6b6 作者: 薛凌堃

使用多线程补采公告

上级 b2546e88
"""
"""
......@@ -90,7 +90,7 @@ class EsMethod(object):
, doc_type='_doc'
, filter_path=filter_path
, body=body)
log.info(result)
# log.info(result)
return result
def updateaunn(self,index_name,id,u_attid):
......@@ -272,7 +272,7 @@ def main(page,p,esMethod):
esMethod.updateaunn(esMethod.index_name, str(id), u_attid)
end_time = time.time()
elapsed_time = end_time - start_time
log.info(f'******更新一条数据耗时{elapsed_time}秒******')
# log.info(f'******更新一条数据耗时{elapsed_time}秒******')
def run_threads(num_threads,esMethod):
threads = []
......@@ -280,8 +280,9 @@ def run_threads(num_threads,esMethod):
page = i + 1
p = i * 200
thread = threading.Thread(target=main, args=(page,p,esMethod))
thread.start()
threads.append(thread)
thread.start()
for thread in threads:
thread.join()
......
"""
"""
......@@ -240,6 +240,7 @@ if __name__ == '__main__':
# esMethod.getFileds(index_name=esMethod.index_name)
page = 1
while True:
start = time.time()
result = esMethod.queryatt(index_name=esMethod.index_name)
total = result['hits']['total']['value']
if total==0:
......@@ -261,7 +262,9 @@ if __name__ == '__main__':
att_id = upload(sourceAddress,num)
u_attid = att_id
esMethod.updateaunn(esMethod.index_name, str(id), u_attid)
log.info(f'200条数据 总耗时{time.time() - start}秒')
page+=1
break
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论