This commit is contained in:
shenjian@fangjia.com
2023-03-09 17:24:10 +08:00
parent e90b282e73
commit 7aa9778413
5 changed files with 21 additions and 10 deletions
@@ -7,12 +7,14 @@ import logging
import sys
from elasticsearch import helpers
from concurrent.futures import ThreadPoolExecutor
from threading import Lock
log = logging.getLogger(__name__)
es206_client = ElasticSearchClient(host='192.168.0.206')
index_name = "community_summary"
mutex = Lock()
def save(community_summary_df):
if 'estate_charge' not in community_summary_df.columns:
@@ -127,7 +129,9 @@ def sync_by_city(city_now):
# 取周边均值
estate_charge = docs['estate_charge'].mean()
if pd.notna(estate_charge):
mutex.acquire(timeout=60)
community_summary_df.loc[index, "estate_charge"] = estate_charge
mutex.release()
for index, item in community_summary_df.iterrows():
pool.submit(deal, index, item)
save(community_summary_df)