优化
This commit is contained in:
@@ -84,7 +84,7 @@ def find_around_price_item(seaweed):
|
|||||||
return
|
return
|
||||||
global find_count
|
global find_count
|
||||||
find_count += 1
|
find_count += 1
|
||||||
if find_count % 1000 == 0:
|
if find_count % 1 == 0:
|
||||||
log.info("已查找" + str(find_count))
|
log.info("已查找" + str(find_count))
|
||||||
|
|
||||||
mutex.acquire()
|
mutex.acquire()
|
||||||
@@ -118,7 +118,7 @@ def find_around_price_item(seaweed):
|
|||||||
}
|
}
|
||||||
|
|
||||||
actions.append(action)
|
actions.append(action)
|
||||||
if len(actions) == 1000:
|
if len(actions) == 10:
|
||||||
helpers.bulk(es206_client.elastic_client, actions)
|
helpers.bulk(es206_client.elastic_client, actions)
|
||||||
log.info("更新:" + str(find_count))
|
log.info("更新:" + str(find_count))
|
||||||
actions.clear()
|
actions.clear()
|
||||||
@@ -128,20 +128,20 @@ def find_around_price_item(seaweed):
|
|||||||
def sync(city=None):
|
def sync(city=None):
|
||||||
log.info("开始同步相对价格排名数据...")
|
log.info("开始同步相对价格排名数据...")
|
||||||
|
|
||||||
tmp_sql = f"select * from community_summary "
|
tmp_sql = f"select * from community_summary where avg_price > 0 "
|
||||||
if pd.notna(city):
|
if pd.notna(city):
|
||||||
tmp_sql += f" where city='{city}'"
|
tmp_sql += f" and city='{city}'"
|
||||||
seaweed_df = tmp_ck.read_sql_query(tmp_sql)
|
seaweed_df = tmp_ck.read_sql_query(tmp_sql)
|
||||||
|
|
||||||
seaweed_list = list()
|
seaweed_list = list()
|
||||||
seaweed_df.apply(lambda x: seaweed_list.append(dict(x)), axis=1)
|
seaweed_df.apply(lambda x: seaweed_list.append(dict(x)), axis=1)
|
||||||
|
|
||||||
with ThreadPoolExecutor(max_workers=30) as pool:
|
# with ThreadPoolExecutor(max_workers=30) as pool:
|
||||||
for seaweed in seaweed_list:
|
# for seaweed in seaweed_list:
|
||||||
pool.submit(find_around_price_item, seaweed)
|
# pool.submit(find_around_price_item, seaweed)
|
||||||
|
|
||||||
# for seaweed in seaweed_list:
|
for seaweed in seaweed_list:
|
||||||
# find_around_price_item(seaweed)
|
find_around_price_item(seaweed)
|
||||||
|
|
||||||
if len(actions) > 0:
|
if len(actions) > 0:
|
||||||
helpers.bulk(es206_client.elastic_client, actions)
|
helpers.bulk(es206_client.elastic_client, actions)
|
||||||
|
|||||||
Reference in New Issue
Block a user